Reputation: 1759
I'm working on a WPF-application in which i have bound a datagrid to entity framework.
This is my datagrid definition:
<DataGrid x:Name="grd_formula_arguments" Grid.Row="1" Grid.Column="2" Style="{StaticResource commonControlStyle}" IsReadOnly="True"
ItemsSource="{Binding FormulaArgumentsAndFields, Mode=TwoWay, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}"
AutoGenerateColumns="False" EnableRowVirtualization="True"
CanUserAddRows="False">
<DataGrid.Columns>
<DataGridTextColumn x:Name="col_attribute_name" Binding="{Binding attribute_name}" Header="Argument"/>
<DataGridTextColumn x:Name="col_assigned_field_name" Binding="{Binding assigned_field_name}" Header="Feld"/>
</DataGrid.Columns>
</DataGrid>
The ItemsSource is bound to a property in the viewmodel, which is a list of my entity formula_field_attributes. That entity contains the columns attribute_name and assigned_field_name. This is the viewmodel property:
public List<formula_field_attributes> FormulaArgumentsAndFields
{
get { return formulaArgumentsAndFields; }
set
{
formulaArgumentsAndFields = value;
RaisePropertyChanged("FormulaArgumentsAndFields");
}
}
At the beginning the list only contains attributenames and assigned_field_name is blank. Then i can assign a fieldname to an attribute in the list.
var argumentname = ((formula_field_attributes)grd_formula_arguments.SelectedItem).attribute_name;
foreach (var item in changeTextProperties.FormulaArgumentsAndFields)
{
if (item.attribute_name == argumentname)
{
item.assigned_field_name = fieldName;
}
}
changeTextProperties.RaisePropertyChanged("FormulaArgumentsAndFields");
When i take a look to the viewmodel property after my operations, it looks fine. But i can't see my changes in the datagrid. What did i wrong?
Thanks in advance!
Upvotes: 0
Views: 438
Reputation: 1759
Meanwhile i resolved the problem by the following steps:
I know it's not what i should do, but it works.
Upvotes: 1