CaliburnMicro中的IsVisible无法链接。

问题描述 投票:0回答:1

在我的Shell视图中,XAML

    <Grid>

....///
    <StackPanel x:Name="SettingsPanelIsVisible" Grid.Row="6" Grid.Column="6" Orientation="Vertical" 
                VerticalAlignment="Bottom" >
        <Button x:Name="Button1" Content="Button 1"/>
        <Button x:Name="Button2" Content="Button 2"/>
    </StackPanel>
</Grid>

而在我的ShellViewModel中

....//
public bool SettingsPanelIsVisible { get; set; }

根据我的理解,这些应该是绑定的,并且应该由caliburn.Micro通过设置或重置bool来切换可见性,然而这并不奏效,尽管其他组件似乎工作正常。

c# xaml mvvm caliburn.micro
1个回答
1
投票

哼,我刚刚读到StackPanel有一些约定俗成的名字,你的错误可能来自于你对viewmodel类的定义(没有看到代码)。

你必须放入viewmodel。 using Caliburn.Micro;

public class ShellViewModel:Screen or PropertyChangedBase
{
     private bool _SettingsPanelIsVisible;
     public bool SettingsPanelIsVisible
    {
        get => _SettingsPanelIsVisible;
        set
        {
            _SettingsPanelIsVisible = value;
            NotifyOfPropertyChange(() => SettingsPanelIsVisible);
        }
    }
    :
}

这个约定与Grid或StackPanel或WrapPanel都是可以的.......

© www.soinside.com 2019 - 2024. All rights reserved.