I’ve got a simple WPF Window, pretty simple, a TextBlock and a Button.
However the button does not react to anything. Not if I move my mouse over it nor if I click it.
Line from the Button:
<Button Margin="3" Command="Close" Content="Ok" Width="50"/>
Full Window Code:
<Window x:Class="Launcher.XAML.MessageWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="self"
Title="{Binding ElementName=self, Path=Caption}" Height="194" Width="477">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Text="{Binding ElementName=self, Path=Message}" Margin="10" TextWrapping="Wrap" />
<StackPanel Grid.Row="1" HorizontalAlignment="Right" Orientation="Horizontal">
<Button Margin="3" Command="Close" Content="Ok" Width="50"/>
</StackPanel>
</Grid>
You need to specify your CommandBindings and Button like so:
And then setup your Executed and CanExecute handlers:
Hope this helps.