I have a listbox which uses an itemtemplate and is bound to a datatable.
I am using datatriggers to do some of the formatting depending on the data in a particular column.
What I want to do is change the binding on the datatrigger programmatically, eg change it from binding to colOne to binding to colTwo.
Can anyone tell me how I can access the triggers and change the binding from code?
Code:<ListBox DockPanel.Dock="Top" Name="ListBox1"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Margin="2" x:Name="txtOne" Text="{Binding Path=ColOne}"></TextBlock> <TextBlock Margin="2" x:Name="txtTwo" Text="{Binding Path=ColTwo}"></TextBlock> <TextBlock Margin="2" x:Name="txtName" Text="{Binding Path=Name}"></TextBlock> </StackPanel> <DataTemplate.Triggers> <DataTrigger x:Name="trigZero" Binding="{Binding Path=ColOne}" Value="0"> <Setter TargetName="txtName" Property="Background" Value="White"></Setter> </DataTrigger> <DataTrigger x:Name="trigOne" Binding="{Binding Path=ColOne}" Value="1"> <Setter TargetName="txtName" Property="Background" Value="Gray"></Setter> </DataTrigger> </DataTemplate.Triggers> </DataTemplate> </ListBox.ItemTemplate> </ListBox>




Reply With Quote