-2
我在XmaI位一个StackLayout
属性控制如下所示:绑定XAML属性可视性视图模型,与按钮
<StackLayout x:Name="_infoView"
Margin="0,10,0,10"
BackgroundColor="Black"
IsVisible="{Binding State}"/>
和在视图模型的结合布尔变量
private Boolean _state = true;
public Boolean State
{
get { return _state; }
set { }
}
我有一个按钮我的XMAL,并希望控制我的StackLayout的知名度,所以我做了这样的事情:
<Button x:Name="CloseButton"
Grid.Row="0"
Grid.Column="3"
Command="{Binding CloseWindowCommand}"/>
和视图模型
CloseWindowCommand = new Command(CloseWindowTapped, CanCloseWindowTapped);
public ICommand CloseWindowCommand { get; set; }
public void CloseWindowTapped()
{
State = false;
}
public bool CanCloseWindowTapped()
{
return true;
}
我认为,通过在CloseButton水龙头,我StackLayout将消失...但它不工作
感谢您的简单和直接的答案!我仍然了解MVVM模型,这非常有帮助! –