Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
785
Binding to current item in XAML
posted

I moved my vanilla SL3 grid to XamWebGrid and I'm very disappointed in its compatibility with the regular grid.

I'm using MVVM and I use an ICollectionView to be able to keep track of the current item and be able to sort from the ViewModel. Sorting from the VM to the grid seems to work OK (I haven't cheked yet the opposite).

 

My problem is that I can't see any way to bind the current grid row to the item, which was handled by the vanilla grid for me. Do I have to handle that myself? I think the XamWebGrid should at least have the basic features of the vanilla SL3 grid.

Parents
No Data
Reply Children
  • 380
    posted in reply to Darrell Kress

    Darrell,

    I'm also using the XamWebGrid with MVVM and have the same request.

    I was able to implement some behaviors that allow me to execute a command when the row changes based on the following blog:

    http://weblogs.asp.net/alexeyzakharov/archive/2009/06/06/silverlight-tips-amp-tricks-make-silverlight-datagrid-be-more-mvvm-friendly.aspx

    I made the changes so that a command is fired on the the XamWebGrid.ActiveCellChanged event.

    My problem at the moment is trying to figure out the XAML binding statement that returns the current Row. If I have the xaml snippet:

                       <igGrid:XamWebGrid
                            x:Name="RequestedDataGrid"
                            d:LayoutOverrides="Width"
                            ItemsSource="{Binding AuditList, Mode=TwoWay}"
                            AutoGenerateColumns="False"
                            Grid.Row="1"
                            igBehavior:DataGridSelectionChanged.Command="{Binding MyTestCommand}"
                            igBehavior:DataGridSelectionChanged.CommandParameter="{Binding      RelativeSource=       {RelativeSource Self}}">
                            <igGrid:XamWebGrid.EditingSettings>
                                <igGrid:EditingSettings
                                    AllowEditing="Cell"
                                    IsMouseActionEditingEnabled="SingleClick" />
                            </igGrid:XamWebGrid.EditingSettings>
                            <igGrid:XamWebGrid.Columns>
                                <igGrid:TextColumn
                                    Key="CheckDate"
                                    IsReadOnly="True"
                                    FormatString="{}{0:d}" />
                                <igGrid:CheckBoxColumn
                                    Key="ReTransmit" />
                            </igGrid:XamWebGrid.Columns>
                        </igGrid:XamWebGrid>

    The CommandParameter will return a reference to the entire grid to my MyTestCommand method as a parameter. What would be the binding statement syntax that returns the current row? I was able to get the row from the grid passed to the method by getting the grid.ActiveCell.Row.Data property. But I don't want to pass the grid to my VM, I just want the current row object. Any help would be appreciated.

    Bob