forum

Home / DeveloperSection / Forums / WPF Showing / Hiding a control with triggers

WPF Showing / Hiding a control with triggers

marcel ethan326018-Jul-2013
Hi experts!

I am trying to create xaml logic to show / hide a control based on the value of the AllowMiscTitle on the ViewModel. The xaml consist of two fields a combobox of the standard tiles ("Mr", "Mrs", ..., "Other") when "Other" is selected I want the textbox to display.

I've created the follow 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>

thanks in advance


Updated on 18-Jul-2013

Can you answer this question?


Answer

1 Answers

Liked By