Hello, I would like to enquire on a solution to as per title.
If the ComboBox is simply a GridViewColumn, it would had been straight-forward like this:
But now that it is in a DataTemplate (of a ListBox), it is more complicated as there's no direct means of accessing the controls.
Below are the codes of what I currently have, simplified:
So basically I'm binding 2 different objects here. 1 to the ListBox, and 1 to the ComboBox. The object that binds to the ListBox has a property which is used as the "SelectedValuePath" of the ComboBox, while the object that binds to ComboBox simply provide the ComboBox with the list of options available for users to choose upon drop-down. Everything is fine as it is, but the only problem is I don't know how to bind the object to the ComboBox in non-MVVM way. If it were a GridViewColumn, I would have solved the problem as shown in my 1st code block.
If the ComboBox is simply a GridViewColumn, it would had been straight-forward like this:
((GridViewComboBoxColumn)gridPrintOption.Columns["PrintCode"]).ItemsSource = listPrintCode;
But now that it is in a DataTemplate (of a ListBox), it is more complicated as there's no direct means of accessing the controls.
Below are the codes of what I currently have, simplified:
<
telerik:RadListBox
Grid.Row
=
"0"
Grid.Column
=
"2"
Margin
=
"0, 5, 5, 5"
x:Name
=
"listBoxIssue"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Top"
Height
=
"690"
Width
=
"793"
ItemTemplate
=
"{StaticResource lbIssueTemplate}"
ItemsSource
=
"{Binding}"
>
<
DataTemplate
x:Key
=
"lbIssueTemplate"
>
<
Grid
Margin
=
"0"
Width
=
"Auto"
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
/>
<
ColumnDefinition
/>
<
ColumnDefinition
/>
</
Grid.ColumnDefinitions
>
<
Grid.RowDefinitions
>
<
RowDefinition
/>
<
RowDefinition
/>
</
Grid.RowDefinitions
>
<
ComboBox
x:Name
=
"PrintCode"
Grid.Row
=
"0"
Grid.Column
=
"2"
ItemsSource
=
"{Binding}"
SelectedValuePath
=
"PrintCode"
DisplayMemberPath
=
"PrintCode"
/>
</
Grid
>
</
DataTemplate
>
So basically I'm binding 2 different objects here. 1 to the ListBox, and 1 to the ComboBox. The object that binds to the ListBox has a property which is used as the "SelectedValuePath" of the ComboBox, while the object that binds to ComboBox simply provide the ComboBox with the list of options available for users to choose upon drop-down. Everything is fine as it is, but the only problem is I don't know how to bind the object to the ComboBox in non-MVVM way. If it were a GridViewColumn, I would have solved the problem as shown in my 1st code block.