I am new to WPF and I am trying to create xaml logic to show / hide a control based on the AllowMiscTitle value in the ViewModel. Xaml consists of two fields: combobox standard fragments ("Mr", "Mrs", ..., "Other") when "Other" is selected. I want the text box to display.
I created the following xaml:
<DockPanel Validation.Error="Validation_Error" HorizontalAlignment="Stretch"> <ComboBox ItemsSource="{Binding Path=Titles, Mode=OneTime}" Text="{Binding Path=Title}"/> <TextBox x:Name="TxtBxTitle" Margin="5,5" Visibility="Visible"> <TextBox.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding Path=AllowMiscTitle}" Value="false"> <Setter Property="TextBox.Visibility" Value="Hidden"/> </DataTrigger> </Style.Triggers> </Style> </TextBox.Style> </TextBox> </DockPanel>
source share