In my WPF C# project, I have a Datagrid as follows:
<DataGrid x:Name="FixedPositionDataGrid" HorizontalAlignment="Left" Margin="33,229,0,0" VerticalAlignment="Top" Width="172" Height="128" AutoGenerateColumns="False" FontSize="10" CanUserAddRows="False">
<DataGrid.Columns>
<DataGridTextColumn Header="indice" Binding="{Binding index}" IsReadOnly="True"/>
<DataGridTextColumn Header="%" Binding="{Binding percentage}" />
<DataGridComboBoxColumn x:Name="DataGridComboBoxColumnAlignment" Header="Allineamento barre" SelectedValueBinding="{Binding alignment}"/>
</DataGrid.Columns>
</DataGrid>
I need to have an event that manages the value changing in second and third columns (that is "%" and "Allineamento barre"). No need about the value inserted, I just need to raise an event when one of values are changed. How can I perform it? I need the way to define the event method in which I can define some operations to do. I've read this how to raise an event when a value in a cell of a wpf datagrid changes using MVVM? but I don't have an observable collection linked to datagrid.
EDIT: The Datagrid ItemSource is linked with the following objects:
public class FixedPosition
{
[XmlAttribute]
public int index { get; set; }
public int percentage { get; set; }
public HorizontalAlignment alignment { get; set; }
}
How can I modify it to obtain the result expected?
Thanks
percentage
and/oralignment
property? That's what is triggered when value changes – dkozlpercentage
I assume it has getterget
and setterset
so trigger what you want to trigger in the setter which will be wheneverpercentage
value has been set:set { ... [trigger action] }
– dkozl