datatrigger

In WPF, how to debug triggers?

蓝咒 提交于 2019-11-29 20:41:48
In WPF, what are some good approaches to debug a trigger such as this? <Trigger Property="IsMouseOver" Value="True"> <Setter Property="FontWeight" Value="Bold"/> </Trigger> Ideally: If the trigger has been hit, I would like a message to be written to the Debug window within Visual Studio; If the trigger is hit, I want Visual Studio to hit a breakpoint in my C# code. Contango There is an excellent article on WPF Mentor by entitled How to debug triggers using Trigger-Tracing (cached version here ). I've used it innumerable times to debug into triggers, it's an amazing technique for anybody that

WPF DataTrigger - Setting ListBoxItem IsSelected

浪尽此生 提交于 2019-11-29 17:29:30
I have the following data trigger on the ListBoxItems in my Multi-selection ListBox <DataTrigger Value="True"> <DataTrigger.Binding> <MultiBinding Converter="{StaticResource DisableWorkItemConverter}"> <Binding ElementName="MainForm" Path="PickedWorkItemID"/> <Binding Path="Id"/> </MultiBinding> </DataTrigger.Binding> <Setter Property="IsEnabled" Value="False"/> <Setter Property="IsSelected" Value="False"/> </DataTrigger> IsEnabled gets set fine, but IsSelected does not get set. How can I fix that? I tried taking out IsEnabled to see if it was conflicting with IsSelected, but the Item remained

Triggers collection members must be of type EventTrigger

半世苍凉 提交于 2019-11-29 16:50:42
问题 I've created a UserControl, similar to the following: <UserControl> <StackPanel Orientation="Vertical"> <StackPanel x:Name="Launch" Orientation="Horizontal" Visibility="Collapsed"> <!-- Children here --> </StackPanel> <ToggleButton x:Name="ToggleLaunch" IsChecked="False" Content="Launch" /> </StackPanel> </UserControl> I've been trying to use a DataTrigger to make the 'Launch' StackPanel become visible when the ToggleButton is checked, and remain collapsed otherwise. However, at runtime I get

wpf datatrigger on an image source

给你一囗甜甜゛ 提交于 2019-11-29 05:58:23
Assuming the binding is right and the image files are where they shuld be, can anyone spot why the image in the xaml below won't change when the trigger evaluates to true? Cheers, Berryl <Image Source="..\..\Images\OK.png" Grid.Column="2" Stretch="None"> <Image.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding TimeSheet, Converter={StaticResource overQuotaConv}}" Value="True"> <Setter Property="Image.Source" Value="..\..\Images\Error.png"/> </DataTrigger> </Style.Triggers> </Style> </Image.Style> </Image> Try the following... Set the TargetType="{x:Type Image}" on the Style Change

MultiDataTrigger vs DataTrigger with multibinding

为君一笑 提交于 2019-11-29 04:59:17
问题 I encountered a situation where I can easily achieve the same functionality by using a MultiDataTrigger or, alternately, using a DataTrigger with a MultiBinding . Are there any substantive reasons to prefer one approach over the other? With MultiDataTrigger: <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding Path=SomePath}" Value="SomeValue"/> <Condition Binding="{Binding Path=SomeOtherPath, Converter={StaticResource SomeConverter}}" Value="SomeOtherValue"/> <

wpf - fire datatrigger when property changes regardless of new value

我们两清 提交于 2019-11-28 21:12:54
I'm trying to execute an animation on a cell in a datagrid when the value of the datagrid cell changes. The datagrid itself is bound to an ObservableCollection of plain old CLR objects. In this case lets say the objects are 'Person' objects with properties for 'Firstname', 'Lastname' and 'Age'. The 'Person' class implements the INotifyPropertyChanged interface and each property has the appropriate call to onPropertyChanged in it's setter. This is all fine. In the datagrid definition I've set my DataTemplate for drawing each cell and attached a datatrigger too ... as follows:

WPF Style DataTrigger with binding to DataContext not working

*爱你&永不变心* 提交于 2019-11-28 20:41:23
I have a TextBox with a style that has a DataTrigger which changes the text, like this: <Grid> <TextBlock Text="Foo"> <TextBlock.Style> <Style BasedOn="{StaticResource TextStyle}" TargetType="TextBlock"> <Style.Triggers> <DataTrigger Binding="{Binding MyBool}" Value="True"> <Setter Property="Text" Value="Bar"/> </DataTrigger> </Style.Triggers> </Style> </TextBlock.Style> </TextBlock> </Grid> But it's not working, the text never changes to "Bar". I have tested using another TextBlock with Text="{Binding MyBool}" and this text changes from "False" to "True". Snoop reveals no errors that I can

Using bindings in DataTrigger condition

倖福魔咒の 提交于 2019-11-28 20:33:01
Let's say I have the following simple classes: public class Person { public int Id { get; set; } public string Name { get; set; } } public class PersonHolder { public Person CurrentPerson { get; set; } public int ActiveId { get; set; } } Now I have a grid with an instance of class PersonHolder as DataContext , and in the grid I have a StackPanel which is bound to the CurrentPerson of PersonHolder - showing its data: <Grid> <StackPanel x:Name="PersonPanel" DataContext="{Binding CurrentPerson}"> <TextBlock Text="{Binding Id}" /> <TextBlock Text="{Binding Name}" /> </StackPanel> </Grid> So - to

In WPF, how to debug triggers?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 16:46:14
问题 In WPF, what are some good approaches to debug a trigger such as this? <Trigger Property="IsMouseOver" Value="True"> <Setter Property="FontWeight" Value="Bold"/> </Trigger> Ideally: If the trigger has been hit, I would like a message to be written to the Debug window within Visual Studio; If the trigger is hit, I want Visual Studio to hit a breakpoint in my C# code. 回答1: There is an excellent article on WPF Mentor by entitled How to debug triggers using Trigger-Tracing (cached version here).

WPF DataTrigger - Setting ListBoxItem IsSelected

杀马特。学长 韩版系。学妹 提交于 2019-11-28 11:01:26
问题 I have the following data trigger on the ListBoxItems in my Multi-selection ListBox <DataTrigger Value="True"> <DataTrigger.Binding> <MultiBinding Converter="{StaticResource DisableWorkItemConverter}"> <Binding ElementName="MainForm" Path="PickedWorkItemID"/> <Binding Path="Id"/> </MultiBinding> </DataTrigger.Binding> <Setter Property="IsEnabled" Value="False"/> <Setter Property="IsSelected" Value="False"/> </DataTrigger> IsEnabled gets set fine, but IsSelected does not get set. How can I fix