multibinding

wpf how to use a converter for child bindings of multibinding?

泪湿孤枕 提交于 2019-12-05 21:41:52
I need a multibinding of bunch boolean properties but with inversing some of these like an example: <StackPanel> <StackPanel.IsEnabled> <MultiBinding Converter="{StaticResource BooleanAndConverter}"> <Binding Path="IsInitialized"/> <Binding Path="IsFailed" Converter="{StaticResource InverseBooleanConverter}"/> </MultiBinding> </StackPanel.IsEnabled> </StackPanel.IsEnabled> But I got a InvalidOperationException from a InverseBooleanConverter with message "The target must be a boolean". My InverseBooleanConverter is: [ValueConversion(typeof(bool), typeof(bool))] public class

Why does MultiBinding with a Converter not work within a ToolTip?

孤街醉人 提交于 2019-12-04 12:47:07
For part of a fairly-complex WPF ToolTip, I'm attempting to use a MultiBinding to produce formatted text based on two properties. The problem is, the binding's MultiConverter receives DependencyProperty.UnsetValue for each item in its values array. The following works, using a single Binding : <ToolTipService.ToolTip> <StackPanel> <TextBlock> <TextBlock.Text> <Binding Path="Amt" Converter="{StaticResource singleValueConverter}"/> </TextBlock.Text> </TextBlock> </StackPanel> </ToolTipService.ToolTip> And so does this, using a MultiBinding with StringFormat : <ToolTipService.ToolTip> <StackPanel

how to edit a WPF textbox which uses multibinding and string.format?

喜你入骨 提交于 2019-12-04 11:46:35
I have the following code. This displays data in following format H:M:S. I would like to edit these values...and wanted to be notified in viewmodel. How do I achieve that ? Any help would be appreciated. Thanks <TextBox DataContext="{Binding UpdateSourceTrigger=PropertyChanged}" > <TextBox.Text> <MultiBinding StringFormat=" {0}:{1}:{2}"> <Binding Path="ValueH" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" /> <Binding Path="ValueM" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" /> <Binding Path="ValueS" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" /> </MultiBinding> </TextBox

putting multibinding on a single line in xaml

只愿长相守 提交于 2019-12-04 10:00:31
问题 Is there a way to take this multibinding: <TextBox.IsEnabled> <MultiBinding Converter="{StaticResource LogicConverter}"> <Binding ElementName="prog0_used" Path="IsEnabled" /> <Binding ElementName="prog0_used" Path="IsChecked" /> </MultiBinding> </TextBox.IsEnabled> and put is all on one line, as in <TextBox IsEnabled="" /> ? If so, where can I learn the rules of this formattiong? 回答1: A better (and simpler) approach would be to define a style as a resource which you can easily apply to any

wpf multibinding to viewmodel?

允我心安 提交于 2019-12-04 07:49:46
For the life of me, I can't seem to bind to my viewmodel using multibindings. All of the examples on the net bind to gui elements directly, but whenever I try with a viewmodel object exceptions are thrown. My question is, how do I add a multibinding to several viewmodel objects in xaml? I need to bind the IsEnabled property of a context menu to two integers in my viewmodel. The following binding doesn't work, since its designed for GUI components. How would I do it to work with my ints? <MenuItem ItemsSource="{Binding MyMenuItem}"> <MenuItem.IsEnabled> <MultiBinding> <Binding ElementName=

WPF MultiBinding - UnsetValue Issue

主宰稳场 提交于 2019-12-04 02:37:58
I have a TextBlock. When its Text is bound as: <Binding Path="Applicant2.Surname"/> It works fine, however I want to include the Forenames so changed the binding to: <MultiBinding StringFormat="{}{0} {1}"> <Binding Path="Applicant2.Forenames"/> <Binding Path="Applicant2.Surname"/> </MultiBinding> This displays {DependencyProperty.UnsetValue} {DependencyProperty.UnsetValue} until the value is set the first time. How can I stop this? Why do I not get the problem with the first simple binding? for a multibinding you need to add a fallback value if it is just blank then you can simply do:

How does FallbackValue work with a MultiBinding?

偶尔善良 提交于 2019-12-04 02:35:19
I ask because it doesn't seem to work. Assume we're binding to the following object: public class HurrDurr { public string Hurr {get{return null;}} public string Durr {get{return null;}} } Well, it would appear that if we used a MultiBinding against this the fallback value would be shown, right? <TextBlock> <TextBlock.Text> <MultiBinding StringFormat="{}{0} to the {1}" FallbackValue="Not set! It works as expected!)"> <Binding Path="Hurr"/> <Binding Path="Durr"/> </MultiBinding> </TextBlock.Text> </TextBlock> However the result is, in fact, " to the " . Even forcing the bindings to return

putting multibinding on a single line in xaml

一笑奈何 提交于 2019-12-03 05:47:51
Is there a way to take this multibinding: <TextBox.IsEnabled> <MultiBinding Converter="{StaticResource LogicConverter}"> <Binding ElementName="prog0_used" Path="IsEnabled" /> <Binding ElementName="prog0_used" Path="IsChecked" /> </MultiBinding> </TextBox.IsEnabled> and put is all on one line, as in <TextBox IsEnabled="" /> ? If so, where can I learn the rules of this formattiong? A better (and simpler) approach would be to define a style as a resource which you can easily apply to any TextBox: <Window.Resources> <c:MyLogicConverter x:Key="LogicConverter" /> <Style TargetType="{x:Type TextBox}"

Bind DataGrid Column Width to Two Colums of Another DataGrid

爱⌒轻易说出口 提交于 2019-12-02 00:37:25
问题 Question: How do I bind StatName.Width to Samp1.ActualWidth + Samp2.ActualWidth ? Sub-questions: Why are my WidthConverter functions never executed (breakpoints never hit)? What is the right <Binding ... syntax for the individual MultiBinding components? What I've tried: I think I need to assign the DataGridTextColumn.Width with MultiBinding and some type of converter. I have tried putting together a solution from various examples online. I can't seem to pull it all together. EDIT With using

Bind DataGrid Column Width to Two Colums of Another DataGrid

丶灬走出姿态 提交于 2019-12-01 21:32:33
Question: How do I bind StatName.Width to Samp1.ActualWidth + Samp2.ActualWidth ? Sub-questions: Why are my WidthConverter functions never executed (breakpoints never hit)? What is the right <Binding ... syntax for the individual MultiBinding components? What I've tried: I think I need to assign the DataGridTextColumn.Width with MultiBinding and some type of converter. I have tried putting together a solution from various examples online. I can't seem to pull it all together. EDIT With using <Binding ElementName="Samp1" Path="ActualWidth" /> No build errors or warnings. The Convert function is