Answer the question
In order to leave comments, you need to log in
C# wpf dataGrid comboBox - why is a type assigned when an option is selected and when data is entered, they are not written?
Hello!
I am new to c# wpf. I am writing my first application and asking for help.
I made a client application that accesses the database and displays its contents in a dataGrid for further editing.
At the same time, 2 problems arose:
1) When a status is selected (in a comboBox), in addition to the status itself, the cell also displays the type:
"System.Windows.Controls.ComboBoxItem: To work" instead of "To work".
Description of ComboBox: (it's in resources)
<DataTemplate x:Key="StatusTemplate" >
<TextBlock Text="{Binding Path=status, ConverterParameter=DefaultToString}"/>
</DataTemplate>
<DataTemplate x:Key="EditingStatusTemplate">
<ComboBox SelectedItem="{Binding Path=status, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" DropDownOpened="ComboBox_DropDownOpened">
<ComboBoxItem Content="Черновик" IsEnabled="True"/>
<ComboBoxItem Content="В работу" IsEnabled="True"/>
<ComboBoxItem Content="В работе" IsEnabled="True"/>
<ComboBoxItem Content="Остановлен" IsEnabled="True"/>
<ComboBoxItem Content="Завершен" IsEnabled="True"/>
<ComboBoxItem Content="Завершен по N2" IsEnabled="True"/>
</ComboBox>
</DataTemplate>
<DataGridTemplateColumn Header="Статус" CanUserResize="False" CellTemplate="{StaticResource StatusTemplate}" CellEditingTemplate="{StaticResource EditingStatusTemplate}"/>
<DataGridTextColumn Binding="{Binding Path=progress}" ClipboardContentBinding="{x:Null}" Header="Прогресс" CanUserResize="False"/>
private void dataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
{
DataGrid dg = dataGrid;
}
private void dataGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question