datatrigger

How can I change the Foreground color of a TextBlock with a Trigger?

♀尐吖头ヾ 提交于 2019-12-10 15:52:36
问题 I want to change foreground color of a TextBlock from dependencyproperty. But I don't change textblock color. I don't know this problem in my code. How can I change the foreground color of a TextBlock with a Trigger? XAML: <TextBlock Name="TestBlock" Text="Test color" > <TextBlock.Style> <Style TargetType="TextBlock"> <Style.Triggers> <Trigger Property ="IsMouseOver" Value="True"> <Setter Property= "Foreground" Value="Gray"/> </Trigger> <DataTrigger Binding="{Binding Path=TestColorMode2,

WPF RotateTransform DataTrigger

 ̄綄美尐妖づ 提交于 2019-12-10 14:57:18
问题 Is it possible to use a DataTrigger to set the angle of a RotateTransform in WPF? If so, how? 回答1: Sure, something like this should work <TextBox> <TextBox.Style> <Style TargetType="TextBox"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text}" Value="RotateMe"> <Setter Property="LayoutTransform"> <Setter.Value> <RotateTransform Angle="45"/> </Setter.Value> </Setter> </DataTrigger> </Style.Triggers> </Style> </TextBox.Style> </TextBox>

Visual indication of last focused item when application loses focus / alternative to IsKeyboardFocusWithin

↘锁芯ラ 提交于 2019-12-10 12:10:58
问题 In an application with multiple panels or documents to interact with, one needs a clear indication of which area of the app has focus. Visual Studio itself is a good example of this. The following MCV Example is close to achieving the desired effect. However, because it uses IsKeyboardFocusWithin , the most recently focused item in the application is not maintained when the application itself loses focus. Desired Behavior: The focused item indicated by blue "SelectedColor" is maintained when

Change WPF UserControl depending on a Property of a TreeViewItem

本秂侑毒 提交于 2019-12-10 11:38:01
问题 My application shows a TreeView on the left with hierarchical ordered items which are all the same type. All the items have a dependency property which can have one of two values. This value is an enum. Depending on this value I want to show one of two UserControls on the left. My idea was to insert both controls and set their opacity to 0. Then I wanted to insert a Style with a DataTrigger that triggers the opacity depending on the enum's value. But I can not access the properties of one

Remove storyboard but keep animated value?

爷,独闯天下 提交于 2019-12-10 02:17:08
问题 How can I remove a storyboard in XAML (i.e. RemoveStoryboard action in a DataTrigger) but keep the value that was animated. Similar to the Animatable.BeginAnimation: If the animation's BeginTime is null, any current animations will be removed and the current value of the property will be held. 回答1: RemoveStoryboard's primary use is to remove the animated values and set them back to their un-animated state. In most cases you can just switch the call to PauseStoryboard or StopStoryboard instead

What does Binding=“{Binding (0)}” mean?

瘦欲@ 提交于 2019-12-08 16:38:09
问题 I found this: <DataTrigger Value="True" Binding="{Binding (0)}"> triggers in RibbonMenuButton template. What does it mean? I've tried to google, but found nothing. UPD more code: <ControlTemplate x:Key="RibbonMenuButtonControlTemplate1" TargetType="{x:Type RibbonMenuButton}"> ... <DataTrigger Binding="{Binding (0)}" Value="True"> <Setter Property="TextElement.Foreground" TargetName="MainGrid" Value="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}"/> <Setter Property="PathFill"

WPF Setting Image.Source from DataTrigger

拈花ヽ惹草 提交于 2019-12-08 15:44:06
问题 I'm trying to define a DataTrigger for an Image element so that it shows a connected/disconnected image. I keep getting an Invalid PropertyDescriptor message. Any ideas? <Image> <Image.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding Source={x:Static my:Server.Instance}, Path=Connected, Mode=OneWay}" Value="True"> <Setter Property="Source" Value="serverconnected.png"/> </DataTrigger> </Style.Triggers> </Style> </Image.Style> </Image> 回答1: I just changed Property="Source" to

Defining DataTrigger for StackPanel

我们两清 提交于 2019-12-08 15:16:43
问题 How do I define a DataTrigger for a StackPanel ? It does have a Trigger property, but defining a trigger here gives the following error on Initialize when starting the application: Failed object initialization (ISupportInitialize.EndInit). Triggers collection members must be of type EventTrigger. .... This is given from the following simple DataTrigger : <StackPanel x:Name="PersonPanel" DataContext="{Binding CurrentPerson}"> <TextBlock Text="{Binding Id}" /> <TextBlock Text="{Binding Name}" /

In WPF, is the FallbackValue used when the binding fails due to null references?

隐身守侯 提交于 2019-12-08 15:04:56
问题 My view-model exposes a list called MyList that may be empty or null . I have an element that I would like hide based on this state. If MyList is empty or null , then the element should be collapsed. If it has elements then it should be shown. Here is my DataTrigger : <DataTrigger Binding="{Binding MyList.Count, FallbackValue=0}" Value="0"> <Setter Property="Visibility" Value="Collapsed"></Setter> </DataTrigger> What happens to this DataTrigger when MyList is null ? Will it use the

Conditionally changing the Foreground of a WPF ComboBox item depending upon a value in the databound ItemsSource item

為{幸葍}努か 提交于 2019-12-08 01:41:17
问题 I have a WPF ComboBox bound to a Collection List<Users> . I have applied a DataTemplate to show the FirstName using a TextBlock and this works as expected: <ComboBox Margin="5" ItemsSource="{Binding Path=TheUsers}" Name="cboUsers"> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Margin="10" Text="{Binding Path=FirstName}"> </TextBlock> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox>` I have an item in my User class called IsActive which is a Boolean value. If true then I want to set