Trouble setting a DataTrigger in WPF
问题 I have a ComboBox and a Button on my main view, and I want to apply a style to the button such that when the combobox index is set to 1, the button becomes visible (initially it's hidden). This is my XAML code: <Grid> <StackPanel Orientation="Vertical" Margin="10"> <ComboBox Name="comboBox"/> <Button Name="myBtn" Content="Hello" Visibility="Hidden"> <Button.Style> <Style TargetType="{x:Type Button}"> <Style.Triggers> <DataTrigger Binding="{Binding ElementName=comboBox, Path=SelectedIndex}"