datatrigger

DataTrigger Usage

二次信任 提交于 2019-12-31 04:27:11
问题 Here is pseudo code for what I want to implement in xaml IF vm.AvatarFilePath IS NOT NULL THEN Image.Source = {Binding AvatarPath} ELSE If vm.Gender == {x:Static vm:Gender.Female} THEN Image.Source = {StaticResource Img_Female} ELSE Image.Source = {StaticResource Img_Male} ENDIF ENDIF and below is an implementation attempt with at least the following issues: how does it know the AvatarPath was null and that we care about Gender? is there a way to do ELSE, so I can specify the Gender.Male

Is it possible to create a generic Int-to-Enum Converter?

99封情书 提交于 2019-12-30 08:14:10
问题 I'd like to be able to say <DataTrigger Binding="{Binding SomeIntValue}" Value="{x:Static local:MyEnum.SomeValue}"> and to have it resolve as True if the int value is equal to (int)MyEnum.Value I know I could make a Converter that returns (MyEnum)intValue , however then I'd have to make a converter for every Enum type I use in my DataTriggers. Is there a generic way to create a converter that would give me this kind of functionality? 回答1: It is possible to create a converter between enum

How can I provide multiple conditions for data trigger in WPF?

孤人 提交于 2019-12-28 03:18:13
问题 How can I provide multiple conditions for data trigger in WPF? 回答1: Use MultiDataTrigger type <Style TargetType="ListBoxItem"> <Style.Triggers> <DataTrigger Binding="{Binding Path=State}" Value="WA"> <Setter Property="Foreground" Value="Red" /> </DataTrigger> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding Path=Name}" Value="Portland" /> <Condition Binding="{Binding Path=State}" Value="OR" /> </MultiDataTrigger.Conditions> <Setter Property="Background" Value=

Storyboard: EventTrigger vs DataTrigger

北战南征 提交于 2019-12-25 11:49:09
问题 Storyboards Overview : Animate when a Property Value Changes provides the following description in a attempt to explain the relationship between "EventTrigger and Storyboard", and between "Trigger (i.e., DataTrigger) and Storyboard" but is sounds a bit ambiguous to me and somehow a short description: Animations applied by property Trigger objects behave in a more complex fashion than EventTrigger animations or animations started using Storyboard methods. They "handoff" with animations defined

Why the TargetedTriggerAction's TargetObject is always null

∥☆過路亽.° 提交于 2019-12-25 08:59:42
问题 I have three Buttons (1.Male,2.Femal,3.OK),I want to change the CommandParameters Property of Button(OK) by Click Male Button or FeMale Button . I found the question Setting a property with an EventTrigger is very helpful to me, but the TargetObject of TargetedTriggerAction<FrameworkElement> in void Invoke(object parameter){...} function is always null , WHY ? HOW Can I to solve the Problem? Error info in output window. System.Windows.Data Error: 4 : Cannot find source for binding with

MultiConverter usage

折月煮酒 提交于 2019-12-25 00:38:13
问题 Here is pseudo code for what I want to implement using a multi-converter. IF vm.AvatarFilePath IS NOT NULL THEN Image.Source = {Binding AvatarPath} ELSE If vm.Gender == {x:Static vm:Gender.Female} THEN Image.Source = {StaticResource Img_Female} ELSE Image.Source = {StaticResource Img_Male} ENDIF ENDIF Please note that I am not convinced that a multi-converter is the right approach, and I posted a similar question that tries to solve this problem with DataTriggers here. My attempt at a

Handling exclusive-or conditions when binding to two boolean properties in XAML

妖精的绣舞 提交于 2019-12-24 03:30:50
问题 So I have a class I want to bind to: public class Awesome { public bool OptionA1 { get; set; } public bool OptionA2 { get; set; } public bool OptionB1 { get; set; } public bool OptionB2 { get; set; } } When I expose this class in my GUI, I have two radio buttons (called radioButtonA and radioButtonB) which let the user pick between groups A and B, and I have two checkboxes to let the user change A1/A2 and B1/B2 respectively depending on which radiobutton ischecked. The logic in the class

Handling exclusive-or conditions when binding to two boolean properties in XAML

一个人想着一个人 提交于 2019-12-24 03:30:29
问题 So I have a class I want to bind to: public class Awesome { public bool OptionA1 { get; set; } public bool OptionA2 { get; set; } public bool OptionB1 { get; set; } public bool OptionB2 { get; set; } } When I expose this class in my GUI, I have two radio buttons (called radioButtonA and radioButtonB) which let the user pick between groups A and B, and I have two checkboxes to let the user change A1/A2 and B1/B2 respectively depending on which radiobutton ischecked. The logic in the class

How to create a WPF-like data trigger in Silverlight?

本小妞迷上赌 提交于 2019-12-24 00:29:32
问题 How might i create a trigger for a Silverlight datagrid in which the cell background color changes based on the cell value? I worked on a WPF project sometime ago and I recall this was quite simple via DataTriggers in the xaml. However this functionality doesn't appear to be available in Silverlight and i'm stuck as to where to start. Thanks all. 回答1: Firstly, the replacement for triggers in Silverlight is the VisualStateManager. The VSM is actually much more powerful than triggers as it

WPF: Activate Trigger when a MVVM bound property changes

霸气de小男生 提交于 2019-12-23 16:09:30
问题 somehow I am going in circles here. Please forgive me if the answer to this question is obvious. I want to react to changed properties in the ViewModel in the View. When the properties (bool) change the View should start an animation (BeginStoryBoard). Actually in my application there are 4 of these properties each with its own name in the VM and two desired animations each (hide/show) for the respective 4 container view elements. When setting these Triggers (tried DataTrigger/Trigger