Hi,@Mojtaba_Hakim.
It can successfully display the default value of the setting without double-clicking. The following sample results can be displayed more clearly.
The DataGrid displays the existing data in the collection, and does not display the data that has not been added.
In my example above, the data that exists in the first row does not need to be clicked to display its value. For the new data that needs to be added, it is necessary to click or other actions to add a new item to display the value of the new item.
I add code CanUserAddRows="True"
in DataGrid and added a property to the object for testing.
<DataGrid
...
CanUserAddRows="True">
<DataGrid.Columns>
<DataGridComboBoxColumn x:Name="ANBAR_COLUMN" MinWidth="80" Width="auto" Header=" انبار "
SelectedValueBinding="{Binding ANBAR,UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="NAMES" SelectedValuePath="CODE">
<DataGridComboBoxColumn.EditingElementStyle>
<Style TargetType="{x:Type ComboBox}">
<Setter Property="IsEditable" Value="True"/>
</Style>
</DataGridComboBoxColumn.EditingElementStyle>
</DataGridComboBoxColumn>
<DataGridTextColumn Header="test" Binding="{Binding Test,UpdateSourceTrigger=PropertyChanged}"/>
</DataGrid.Columns>
</DataGrid>
Codebedhind:
private void Window_Loaded(object sender, RoutedEventArgs e)
{
FillALLComboboxes();
List<INVO_LST_RASID_KHARID_CSHARP> QRE_LST = new List<INVO_LST_RASID_KHARID_CSHARP>();
QRE_LST.Add(new INVO_LST_RASID_KHARID_CSHARP() { Test="test1"});
INVO_DATA_RASID_KHARID?.Clear();
foreach (var item in QRE_LST)
INVO_DATA_RASID_KHARID.Add(item);
}
public class INVO_LST_RASID_KHARID_CSHARP : INotifyPropertyChanged, ICloneable
{
...
private string test;
public string Test
{
get
{
return test;
}
set
{
if (test == value)
return;
test = value;
OnPropertyChanged("Test");
}
}
}
The result:
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.