开发者

Silverlight ComboBox ItemSource Binding DynamicResource

开发者 https://www.devze.com 2023-04-03 13:43 出处:网络
I have a ComboBox defined in a Styles.xaml file. The ViewModel object is defined as a resource in the MainPage.xaml file. The ItemSource of the ComboBox is a List in the ViewModel. Hence, I need the b

I have a ComboBox defined in a Styles.xaml file. The ViewModel object is defined as a resource in the MainPage.xaml file. The ItemSource of the ComboBox is a List in the ViewModel. Hence, I need the binding for the ItemSource to look for the list at runtime and not in the Style file. What can I do for this?

<ComboBox Grid.Column="1"
          HorizontalAlignment="{TemplateBinding HorizontalContentA开发者_如何学编程lignment}"
          Margin="{TemplateBinding Padding}"
          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
          ItemContainerStyle="{StaticResource ComboBoxItemStyle}"
          ItemsSource="{Binding Source={StaticResource vm}, Path=WtItemSource}"
          Style="{StaticResource HorizontalComboBox}"
          Width="70"
          d:LayoutOverrides="Width" />

Here, vm is the viewmodel object, but is defined in MainPage.xaml as,

 <local:Util x:Key="vm"/>
0

精彩评论

暂无评论...
验证码 换一张
取 消