I have WPF application created in .net framework 3.5 which uses MVVM
pattern. I have a wpftoolkit Datagrid which has a column which consists
of combobox
with in the datatemplate. My datagrid is binded to a data table present
in the ViewModel.
I
need to bind the SelectedItem property of the combobox present in
Datagrid to one of the column present in Datatable. Basically I also
have textblock and textbox
with in the datagrid, but this controls get properly binded to datatable
columns.
Following is the Xaml code snippet :
TextBox Binding(Working properly ) :
<toolkit:DataGridTemplateColumn.CellTemplate>
<DataTemplate >
<TextBox BorderThickness="0" Text="{Binding TxtbindedColumn}" />
</DataTemplate>
</toolkit:DataGridTemplateColumn.CellTemplate>
ComboBox binding :
<ComboBox x:Name="Cmb1"
AutomationProperties.AutomationId="Cmb1" AutomationProperties.Name="Cmb1"
ItemsSource="{Binding
DataContext.ComboEntity,RelativeSource={RelativeSource
AncestorType={x:Type wpfwiz:WizardResultPageBase}}}"
DisplayMemberPath="Desc"
SelectedValuePath="Id"
TabIndex="3"
Foreground="Black"
IsSynchronizedWithCurrentItem="False"
SelectedItem="{Binding CmbbindedColumn}">
</ComboBox>
Datatable in Viewmodel :
public DataTable PagedGridList
{
get
{
return _pagedGridList;
}
set
{
_pagedGridList = value;
if (_pagedGridList != null)
{
_pagedGridList.Columns[0].ColumnName = " TxtbindedColumn ";
_pagedGridList.Columns[1].ColumnName = " CmbbindedColumn ";
}
}
}
Need a urgent help on this.
No comments:
Post a Comment