datatrigger

WPF Animation with datatriggers

倾然丶 夕夏残阳落幕 提交于 2019-12-07 20:23:24
问题 I have a rectangle which I am animating the backround colour of. It should change to green each time a particular number goes up. And red when it goes dowm. If the number doesn't change for a while it slowly fades back to its default colour So the animation changes th background from grey to red very quickly and then takes several seconds to fade back to grey. I have added as DataTrigger which is bound to 1 or -1 depending on how the number has changed The problem is that if the number keeps

Usage DataTrigger in WPF

允我心安 提交于 2019-12-07 07:17:24
I have a TextBox control defined in XAML and I want to apply different background colors to the TextBox based on its IsReadOnly or IsEnabled properties. I used dataTriggers to actually switch between the colors as shown below: <Style x:Key="TextBoxStyle" TargetType="TextBox"> <Style.Triggers> <DataTrigger Binding="{Binding IsEnabled}" Value="True"> <Setter Property="TextBox.Background" Value="Yellow"/> </DataTrigger> <DataTrigger Binding="{Binding IsReadOnly}" Value="True"> <Setter Property="TextBox.Background" Value="Red"/> </DataTrigger> <MultiDataTrigger> <MultiDataTrigger.Conditions>

Why can't I use a DataTrigger to set TextBox.IsEnabled = True?

▼魔方 西西 提交于 2019-12-07 06:24:33
问题 In my application, I have a TextBox that I want to enable/disable based on an enum in my datacontext. The enum has three values (Anyone, Me, Someone) and I want to enable the Textbox when the value "Someone" is set. I am able to hack a solution by setting the value in reverse (see below). However, can someone please explain why the first solution didn't work? This does not work... <TextBox Text="{Binding ModifiedUser, UpdateSourceTrigger=PropertyChanged}" IsEnabled="False"> <TextBox.Style>

Blend Trigger vs. WPF Trigger

妖精的绣舞 提交于 2019-12-07 04:08:18
问题 It seems to me that there is a major difference between the Blend-style Trigger s found in the Interactivity namespace, and the classic Trigger s available via Styles, ControlTemplate s, etc, in WPF (I supposed this probably applies to SilverLight as well). In WPF, when you set a Trigger with a Setter, you get two behaviours: if the trigger condition is met, the Setter is applied. However, once a Trigger is no longer satisfied, the previous value is restored. This is tremendously useful when

TemplateBinding from a Style DataTrigger In ControlTemplate

[亡魂溺海] 提交于 2019-12-07 02:28:47
问题 In the following XAML I'm using a Rectangle with a Border as the Template for a ToggleButton. I want the BorderBrush to be a different colour to reflect the changing value of ToggleButton.IsChecked. Unfortunately my attempt here of using a TemplateBinding in the DataTrigger doesn't work. What do I need to do instead? <StackPanel Orientation="Horizontal"> <StackPanel.Resources> <ControlTemplate x:Key="ButtonAsSwatchTemplate"> <Border BorderThickness="1"> <Border.Style> <Style> <Setter Property

How to combine DataTrigger and EventTrigger?

白昼怎懂夜的黑 提交于 2019-12-06 17:27:51
问题 NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I'm after: when an item appears in my ListBox, it should flash for a few moments if the item is 'Critical' then it should remain highlighted Currently I have a DataTemplate that looks like this: <DataTemplate DataType="{x:Type Notifications:NotificationViewModel}"> <Grid HorizontalAlignment="Stretch"> <Border Name

WPF Animation with datatriggers

萝らか妹 提交于 2019-12-06 09:29:49
I have a rectangle which I am animating the backround colour of. It should change to green each time a particular number goes up. And red when it goes dowm. If the number doesn't change for a while it slowly fades back to its default colour So the animation changes th background from grey to red very quickly and then takes several seconds to fade back to grey. I have added as DataTrigger which is bound to 1 or -1 depending on how the number has changed The problem is that if the number keeps going up the animation does not get restarted. e.g. if the sequence of numbers went 1, 2, 3, 4, 5. Then

DataTrigger in CellTemplate binding to HeaderTemplate; can it work?

本小妞迷上赌 提交于 2019-12-06 07:22:56
The goal here would be to check all grid checkboxes if the header checkbox changes: <Window.Resources> <Style TargetType="CheckBox" x:Key="InnerBox"> <Setter Property="HorizontalAlignment" Value="Center" /> <Style.Triggers> <DataTrigger Value="True" Binding="{Binding IsChecked, ElementName=HeaderCheckbox}"> <Setter Property="IsChecked" Value="True" /> </DataTrigger> <DataTrigger Value="False" Binding="{Binding IsChecked, ElementName=HeaderCheckbox}"> <Setter Property="IsChecked" Value="False" /> </DataTrigger> </Style.Triggers> </Style> </Window.Resources> <DataGrid> <DataGrid.Columns> <!--

WPF ListViewItem lost focus event - How to get at the event?

你说的曾经没有我的故事 提交于 2019-12-06 07:09:36
问题 I have a listview that you select a row/item on. This is linked to a datatrigger that displays an image on the row. The image should only be displayed when the row is selected. This part works fine, however when you move the focus to something else, such as a textbox, or a messagebox is displayed, the listviewitem loses focus ie the highlight on the row is no longer displayed. The problem is that my image still remains. It should be hidden/collapsed when the listview loses focus... It works

Datatrigger on contentpresenter.content not working

风流意气都作罢 提交于 2019-12-06 04:45:48
问题 I am trying to switch the content of a contentpresenter based on a datatrigger.I want to display a usercontrol in the contentpresenter.content, if i have a value set or else i need to display an error message.But the binding on my datatrigger fails stating that the property is not found.I cant get the datacontext to inherit for the datatrigger checking.I can make it work by using the commented out code.But i am confused why it doesn't work the normal way. <ContentPresenter.Style> <Style