我有一个带8个按钮的WPF应用程序。其中四个工作正常。然后我添加了另外4个按钮。由于某种原因,这些按钮不会绑定到我的视图模型。当我点击按钮时,我的视图模型中没有调用任何内容。一切看起来和我的四个工作按钮一样,对于我的生活,我看不出为什么这些新按钮不能绑定到我的视图模型?
查看模型
public ICommand CommandButtAppendComments { get; set; }
private bool _appendbuttVisibleComments;
public bool AppendButtVisibleComents
{
get { return _appendbuttVisibleComments; }
set
{
_appendbuttVisibleComments = value;
OnPropertyChanged("AppendButtVisibleComents");
}
}
public ViewModel()
{
CommandButtAppendComments = new MyCommands(ExecuteCommandButtAppendComments, CanExecuteCommandButtAppendComments);
}
#region Append Comments Button
private bool CanExecuteCommandButtAppendComments(object parameter)
{
return true;
}
private void ExecuteCommandButtAppendComments(object parameter)
{
AppendButtVisibleComents = false;
DetachButtVisibleComents = true;
}
#endregion
XAML
<Window.Resources>
<BooleanToVisibilityConverter x:Key="BoolToVis"/>
</Window.Resources>
<Button Grid.Row="0" Grid.Column="5" Height="30" Width="60" Content="Append" Command="{Binding CommandButtAppendComments}" Style="{StaticResource ButtonTemplate}" Visibility="{Binding AppendButtVisibleComents, Converter={StaticResource BoolToVis}}"/>