Caliburn-Micro / Caliburn.Micro

A small, yet powerful framework, designed for building applications across all XAML platforms. Its strong support for MV* patterns will enable you to build your solution quickly, without the need to sacrifice code quality or testability.
http://caliburnmicro.com/
MIT License
2.79k stars 775 forks source link

Caliburn Micro 4.0.212 doesn't update row data in ViewModel #889

Closed Aixtreme-Agile closed 10 months ago

Aixtreme-Agile commented 10 months ago

Hello all, I have a problem with datagrid and need your help to solve it. I am using Microsoft VS 2022 Professional, .NET 6.0 I created a simple datagrid and I want to get the row data in my view model every time the RowEditEnding is triggered. The model has initial value:

public class DemoModel
{
    public string FirstName { get; set; } = "---";
    public string LastName { get; set; } = "---";
    public string Age { get; set; } = "18";
    public bool Saved { get; set; } = false;
}

CaliburnMicro_Net6_Datagrid_01

CaliburnMicro_Net6_Datagrid_02

    <Grid>
        <DataGrid x:Name="DemoDataGrid"
            HorizontalAlignment="Center" VerticalAlignment="Top"
            ItemsSource="{Binding Path=DemoData}"
            SelectedItem="{Binding Path=SelectedDemoData}"
            cal:Message.Attach="[Event RowEditEnding]=[Action SaveRowChanges()]"
            IsSynchronizedWithCurrentItem="True"
            AutoGenerateColumns="False"
            ColumnWidth="SizeToHeader">
            <DataGrid.Columns>
                <DataGridTextColumn
                    Width="100"
                    Binding="{Binding Path=FirstName}"
                    Header="FirstName"
                    IsReadOnly="False" />
                <DataGridTextColumn
                    Width="100"
                    Binding="{Binding Path=LastName}"
                    Header="LastName"
                    IsReadOnly="False" />
                <DataGridTextColumn
                    Width="100"
                    Binding="{Binding Path=Age}"
                    Header="Age"
                    IsReadOnly="False" />
            </DataGrid.Columns>
        </DataGrid>
    </Grid>

CaliburnMicro_Net6_Datagrid_03a

The content of Selected Item:

CaliburnMicro_Net6_Datagrid_03b

How can I get the actual row data using RowEditEnding event? Or is there any other better event, that should be used? Thank you in advance.

Mr. Yoo

Aixtreme-Agile commented 10 months ago

Sorry for the wrong issue. I have solved it. This issue is closed.