Note that there are some explanatory texts on larger screens.

plurals
  1. POBind command from Business object to View in MVVM
    primarykey
    data
    text
    <p>I populate DataGrid in WPF through MVVM. I have business object with 4 properties to create the Row and Columns in the DataGrid.</p> <pre><code>&lt;DataGrid CanUserAddRows="True" ItemsSource="{Binding Path=PersonsInfo}" AutoGenerateColumns="False" CanUserDeleteRows="True" CanUserReorderColumns="True" CanUserSortColumns="True"&gt; &lt;DataGrid.Columns&gt; &lt;DataGridTextColumn Header="Name" Binding="{Binding Path=Name}"/&gt; &lt;DataGridTextColumn Header="Age" Binding="{Binding Path=Age}"/&gt; &lt;DataGridTextColumn Header="Date Of Birth" Binding="{Binding Path=DateOfBirth}"/&gt; &lt;DataGridTextColumn Header="Address" Binding="{Binding Path=Address}"/&gt; &lt;DataGridTemplateColumn&gt; &lt;DataGridTemplateColumn.CellTemplate&gt; &lt;DataTemplate&gt; &lt;Grid&gt; &lt;Button Content="Remove..." Margin="3" Command="{Binding Path=RemoveCommand}" /&gt; &lt;/Grid&gt; &lt;/DataTemplate&gt; &lt;/DataGridTemplateColumn.CellTemplate&gt; &lt;/DataGridTemplateColumn&gt; &lt;/DataGrid.Columns&gt; &lt;/DataGrid&gt; </code></pre> <p>In the above code when I click the button, I need to remove the records from the DataGrid.</p> <p>So I need the requirement that, I should be having the Command in the business object class instead of having inside the ViewModel class.</p> <p>While I am clicking the button in each row, that corresponding row should be deleted.</p> <p>Hence how can I find which item is selected in the DataGrid to delete the row through command execution in business object class because business object class does not have information about items of the DataGrid?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload