multibinding

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"/> <

How can I pass a constant value for 1 binding in multi-binding?

偶尔善良 提交于 2019-11-28 16:17:01
I have a multi-binding like <TextBlock> <TextBlock.Text> <MultiBinding Converter="{StaticResource myConverter}"> <Binding Path="myFirst.Value" /> <Binding Path="mySecond.Value" /> </MultiBinding> </TextBlock.Text> </TextBlock> And I want to pass a fixed value e.g. "123" to one of the two bindings above. How can I do that using XAML? Noldorin If your value is simply a string , you can specify it as a constant in the Source property of a binding. If it is any other primitive data type, you need to define a static resource and reference this. Define the sys namespace in the root of the XAML to

Issue while mixing MultiBinding converter and Trigger in style

走远了吗. 提交于 2019-11-27 16:11:00
问题 Setting the style in <UserControl.Resources> (assuming the converter returns the color Red) <Style x:Key="FieldToValidate" TargetType="{x:Type TextBox}"> <Setter Property="Background"> <Setter.Value> <MultiBinding Converter="{StaticResource VisualQueueOnErrorConverter}"> <Binding RelativeSource="{RelativeSource self}" Path="Name" /> <Binding RelativeSource="{RelativeSource AncestorType={x:Type DockPanel}}" Path="DataContext.ErrorFieldName" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay" /

StringFormat and Multibinding with Label

跟風遠走 提交于 2019-11-27 15:27:38
问题 I would like to use StringFormat to do someting like this : <Label x:Name="myLabel"> <Label.Content> <Multibinding StringFormat="{}{0} - {1}"> <Binding Path="Lib1" /> <Binding Path="Lib2" /> </MultiBinding> </Label.Content> </Label> However, it's doesn't work and I got this error instead : MultiBinding failed because it has no valid Converter. MultiBindingExpression:target element is 'Label' (Name='myLabel'); target property is 'Content' (type 'Object') Is there any way to make this code work

String format using MultiBinding?

假如想象 提交于 2019-11-27 07:26:49
I'm trying to display a string in XAML using Label control. Following is my XAML code : <Label Height="28" HorizontalAlignment="Left" Margin="233,68,0,0" Name="label13" VerticalAlignment="Top"> <Label.Content> <MultiBinding StringFormat="{}{0} x {1}"> <Binding Path="Width" /> <Binding Path="Height" /> </MultiBinding> </Label.Content> Width and Height are two properties of my class Movie. I want the label to display : "Width x Height" ex. 800 x 640 However the label control remains empty. Any help is appreciated. I WANT TO DO THIS WITHOUT USING A CONVERTER. I have modified my xaml by using a

How to bind multiple values to a single WPF TextBlock?

☆樱花仙子☆ 提交于 2019-11-26 11:05:34
I'm currently using the TextBlock below to bind the value of a property named Name : <TextBlock Text="{Binding Name}" /> Now, I want to bind another property named ID to the same TextBlock . Is it possible to bind two or more values to the same TextBlock ? Can it be done with simple concatenation, like Name + ID and, if not, how else could this be approached? Richard McGuire You can use a MultiBinding combined with the StringFormat property. Usage would resemble the following: <TextBlock> <TextBlock.Text> <MultiBinding StringFormat="{}{0} + {1}"> <Binding Path="Name" /> <Binding Path="ID" /> <