Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem while binding DataGridComboBoxColumn in Datagrid
    text
    copied!<p>I am novice in WPF. I have a wpftoolkit datagrid where i am using a combo box as datagridcombox column. I am using a observable collection of Codes for binding the combo box. Below is the collection and its class...</p> <pre class="lang-vb prettyprint-override"><code>#Region "Class &amp; Coll" Public Class CodesColl Inherits ObservableCollection(Of Codes) End Class Public Class Codes Private pCode As String Private pDescription As String Public Sub New() pCode = String.Empty pDescription = String.Empty End Sub #End Region #Region "Property" Public Property fldCode() As String Get Return pCode End Get Set(ByVal value As String) pCode = value End Set End Property Public Property fldDescription() As String Get Return pDescription End Get Set(ByVal value As String) pDescription = value End Set End Property #End Region End Class </code></pre> <p>Now what i want achieve is that i need to bind the collection with dropdown in the grid.In my grid i have two columns in first column i have to display the code (fldCode) , and on the selection of the code the next column of the same row will get populated with its description (fldDescription). </p> <p>My Xaml is something like this:</p> <pre><code>&lt;wpfkit:DataGrid Margin="3" Style="{DynamicResource SimpleDataGrid}" FontWeight="Normal" MaxHeight="100" ItemsSource="{Binding Source={StaticResource odpExistingCodesColl}}" AutoGenerateColumns="False" Name="dgCodes" VerticalScrollBarVisibility="Visible" &gt; &lt;wpfkit:DataGrid.Columns&gt; &lt;wpfkit:DataGridTemplateColumn IsReadOnly="True"&gt; &lt;wpfkit:DataGridTemplateColumn.CellTemplate&gt; &lt;DataTemplate&gt; &lt;Image Style="{DynamicResource SimpleImageDelete}"/&gt; &lt;/DataTemplate&gt; &lt;/wpfkit:DataGridTemplateColumn.CellTemplate&gt; &lt;/wpfkit:DataGridTemplateColumn&gt; &lt;wpfkit:DataGridComboBoxColumn Header="Code" DisplayMemberPath="fldCode" SelectedValueBinding="{Binding fldCodes.fldCode}" SelectedValuePath="fldCode" SelectedItemBinding="{Binding fldCodeList}" Width="100" x:Name="cbTCodes" &gt; &lt;wpfkit:DataGridComboBoxColumn.ElementStyle&gt; &lt;Style TargetType="ComboBox"&gt; &lt;Setter Property="IsSynchronizedWithCurrentItem" Value="False" /&gt; &lt;Setter Property ="ItemsSource" Value="{Binding Path=odpCodesColl}"/&gt; &lt;/Style&gt; &lt;/wpfkit:DataGridComboBoxColumn.ElementStyle&gt; &lt;wpfkit:DataGridComboBoxColumn.EditingElementStyle &gt; &lt;Style TargetType="ComboBox"&gt; &lt;Setter Property ="ItemsSource" Value="{Binding Path=odpCodesColl}"/&gt; &lt;Setter Property ="IsDropDownOpen" Value="True"/&gt; &lt;/Style&gt; &lt;/wpfkit:DataGridComboBoxColumn.EditingElementStyle&gt; &lt;/wpfkit:DataGridComboBoxColumn&gt; &lt;wpfkit:DataGridTextColumn Width="375" Header="Description" x:Name="tbTCodeDescription" /&gt; &lt;/wpfkit:DataGrid.Columns&gt; &lt;/wpfkit:DataGrid&gt; </code></pre> <p>odpExistingCodesColl here is another collection through which i am binding the entire grid and is used for sending the code and its description to but i am facing following problems</p> <ol> <li>Unable to display the codes in dropdown.</li> <li>Somehow i manged to do so but it disappears after loosing focus from the combobox.</li> <li>Unable to retrive the description on its selection change as , i am unable to find the event too.</li> </ol> <p>So you guys are requested to help me out asap.. any help will be highly appreciated.. Thanks in Advance Amit Ranjan</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload