Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <ListBox DataContext="{Binding}" x:Name="AnswerListBox" ItemContainerStyle="{StaticResource QuestionStyle}" Grid.Row="1" Width="Auto" Grid.Column="2" ItemsSource="{Binding Path=AnswerList}" BorderBrush="{x:Null}" />
- <Style TargetType="ListBoxItem" x:Key="QuestionStyle">
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="ListBoxItem">
- <StackPanel Background="Transparent" >
- <RadioButton Visibility="{Binding Path=QuestionType, Converter={StaticResource QuestionTypeConverter}, ConverterParameter='RadioButtonStyle'}" Height="auto" Margin="0,0,0,10" IsChecked="{TemplateBinding IsSelected}" IsHitTestVisible="False" Content="{Binding Path=AnswerText}">
- </RadioButton>
- <CheckBox Visibility="{Binding Path=QuestionType, Converter={StaticResource QuestionTypeConverter}, ConverterParameter='CheckBoxStyle'}" Height="auto" Margin="0,0,0,10" Content="{Binding Path=AnswerText}">
- </CheckBox>
- </StackPanel>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <UserControl x:Class="SomeApp.Views.MainPageView" x:Name="control" >
- <ListBox ItemsSource="{Binding Path=SomeItems}" >
- <ListBox.ItemTemplate>
- <DataTemplate>
- <StackPanel Orientation="Horizontal">
- <TextBlock Text="{Binding ElementName=control, Path=DataContext.Threshold}"/>
- </StackPanel>
- </DataTemplate>
- </ListBox.ItemTemplate>
- </ListBox>
- class ViewModel{
- ObservableCollection<ComboboxListItemType> DataForTheComboBoxList;
- ObservableCollection<MyDataType> DataForTheListBox;
- ...
- }
- public partial class MyDataType
- {
- private ObservableCollection<ComboboxListItemType> m_AllComboboxItems;
- public ObservableCollection<ComboboxListItemType> AllComboboxItems
- {
- get { return m_AllComboboxItems; }
- set
- {
- if (m_AllComboboxItems != value)
- {
- m_AllComboboxItems = value;
- RaisePropertyChanged("AllComboboxItems");
- }
- }
- }
- }
- // in ViewModel class
- foreach(var x in this.DataForTheListBox)
- {
- x.AllComboboxItems = this.DataForTheComboBoxList;
- }
- <DataTemplate x:Key="ListBoxItemTemplate">
- ...
- <Combobox
- ItemsSource="{Binding AllComboboxItems}"
- SelectedItem="{Binding CurrentBlah}"/>
- </DataTemplate>
Add Comment
Please, Sign In to add comment