Wpf日历组合框多重绑定 [英] Wpf calendar combobox multibinding
本文介绍了Wpf日历组合框多重绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我有一个WPF,C#问题。我想将组合框值放入日历中
WPF代码:
< ComboBox Name = cbWorkerHorizontalAlignment =LeftMargin =96,10,0,0VerticalAlignment =TopWidth =198
ItemsSource ={Binding Path = Companies}SelectedItem ={Binding Path = Company }>
< / ComboBox>
< Label Content ={Binding Path = Company}HorizontalAlignment =LeftMargin =10,6,0,0VerticalAlignment =Top/>
< Calendar Name =KalenderTag ={Binding Path = Company}SelectedDatesChanged =Calendar_SelectedDatesChangedHorizontalAlignment =LeftMargin =10,10,10,10VerticalAlignment =顶部>
< Calendar.CalendarDayButtonStyle>
< Style TargetType ={x:Type CalendarDayButton}>
< Setter Property =Background>
< Setter.Value>
< MultiBinding Converter ={StaticResource formatterView}>
< Binding Path =Company/>
< Binding Path =Date/>
< / MultiBinding>
< /Setter.Value>
< / Setter>
< / Style>
< /Calendar.CalendarDayButtonStyle>
< / Calendar>
问题是Label显示正确的值,但多重绑定显示{DependencyProperty。 ComboBox值的UnsetValue}。
我尝试过:
显示值的标签,但它有效,只有多重绑定不起作用。
解决方案
我在Binding FallbackValue =添加了它的工作原理
Hello,
i hava got a WPF, C# problem. I want to get the combobox value into the calendar
The WPF Code:
<ComboBox Name="cbWorker" HorizontalAlignment="Left" Margin="96,10,0,0" VerticalAlignment="Top" Width="198" ItemsSource="{Binding Path=Companies}" SelectedItem="{Binding Path=Company}" > </ComboBox> <Label Content="{Binding Path=Company}" HorizontalAlignment="Left" Margin="10,6,0,0" VerticalAlignment="Top"/> <Calendar Name="Kalender" Tag="{Binding Path=Company}" SelectedDatesChanged="Calendar_SelectedDatesChanged" HorizontalAlignment="Left" Margin="10,10,10,10" VerticalAlignment="Top"> <Calendar.CalendarDayButtonStyle> <Style TargetType="{x:Type CalendarDayButton}"> <Setter Property="Background" > <Setter.Value> <MultiBinding Converter="{StaticResource formatterView}"> <Binding Path="Company" /> <Binding Path="Date" /> </MultiBinding> </Setter.Value> </Setter> </Style> </Calendar.CalendarDayButtonStyle> </Calendar>
The problem is that the Label shows the right value but the multi binding says {DependencyProperty.UnsetValue} for the ComboBox value.
What I have tried:
The label to show the value but it works and only the multi Binding did not work.
解决方案
I added at the Binding FallbackValue="" and it works
这篇关于Wpf日历组合框多重绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文