Xceed DataGrid for Silverlight Documentation
SelectedItem Property (DataGridControl)
Example 


Gets or sets the currently selected data item.
Syntax
'Declaration
 
Public Property SelectedItem As Object
'Usage
 
Dim instance As DataGridControl
Dim value As Object
 
instance.SelectedItem = value
 
value = instance.SelectedItem
public object SelectedItem {get; set;}

Property Value

An object representing the currently selected data item. Can be a null reference (Nothing in Visual Basic) if no item is selected.
Exceptions
ExceptionDescription
System.InvalidOperationExceptionThe SelectedItem property can only be used with a synchronous data source. When using an asynchronous data source, the BeginGetSelectedItems and EndGetSelectedItems methods must be used instead.
Remarks

If more than one item is selected, the SelectedItem property will return the last item that was selected.

The SelectedItem and SelectedItems properties can only be used with a synchronous data source. When used with a asynchronous data source, an exception will be thrown.

Example
<sldg:DataGridControl x:Name="sldgDataGridControl"
                      ItemsSource="{Binding Path=People}">
   <sldg:DataGridControl.FixedFooters>
      <StackPanel Orientation="Horizontal">
         <TextBlock Text="{Binding ElementName=sldgDataGridControl,
                                   Path=SelectedItem.FirstName, StringFormat='{}{0} '}" />
         <TextBlock Text="{Binding ElementName=sldgDataGridControl,
                                   Path=SelectedItem.LastName, StringFormat='{}{0} '}" />
         <TextBlock Text="{Binding ElementName=sldgDataGridControl,
                                   Path=SelectedItems.Count, StringFormat='({0} items are selected)'}" />
      </StackPanel>
   </sldg:DataGridControl.FixedFooters>
</sldg:DataGridControl>
Requirements

Target Platforms: Windows 7, Windows Vista, Windows XP SP3, Windows Server 2008 family

See Also

Reference

DataGridControl Class
DataGridControl Members

Asynchronous Operations

BeginGetSelectedItems Method
EndGetSelectedItems Method

Manipulating Data

Selecting Data

Send Feedback