Hi,
I am trying/testing the XAML that were shown in one of the lessons of the CBT-nuggets for the exam 70-511.
When I select the option 'one' from the combobox, it should set the text 'you have selected one' to the textbox.
But this is not working.
What have I missed?
Thanks in advance.
Code:<Window x:Class="WpfApplication6.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <Grid.Resources> <Style TargetType="{x:Type Label}"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="pink"/> </Trigger> </Style.Triggers> </Style> <Style TargetType="{x:Type TextBox}"> <Style.Triggers> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="IsMouseOver" Value="True" /> <Condition Property="Text" Value="" /> </MultiTrigger.Conditions> <Setter Property="Background" Value="Aqua"/> </MultiTrigger> </Style.Triggers> </Style> </Grid.Resources> <Label Content="Hover over me" Margin="5,0,392,287" /> <Label Content="Hover over me also" Height="27" HorizontalAlignment="Left" Margin="5,30,0,0" Name="label1" VerticalAlignment="Top" Width="120" /> <TextBox Height="23" HorizontalAlignment="Left" Margin="12,63,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" /> <ComboBox Name="combo" Height="22" HorizontalAlignment="Left" Margin="12,92,0,0" VerticalAlignment="Top" Width="134"> <ComboBoxItem Content="one" /> <ComboBoxItem Content="two" /> <ComboBoxItem Content="three" /> </ComboBox> <TextBox IsReadOnly="True" DataContext="{Binding ElementName=combo, Path=SelectedItem}" Height="22" HorizontalAlignment="Left" Margin="152,92,0,0" VerticalAlignment="Top" Width="152"> <TextBox.Resources> <Style TargetType="{x:Type TextBox}"> <Style.Triggers> <DataTrigger Binding="{Binding}" Value="one"> <Setter Property="Text" Value="You have selected one" /> </DataTrigger> </Style.Triggers> </Style> </TextBox.Resources> </TextBox> </Grid> </Window>


Reply With Quote
Bookmarks