We are using MVVM Light Silverlight project for WCF Ria Service based project. After some research we decided to use DevExpress DataGrid with RiaInstantFeedbackDataSource. Everything works great until we wanted to bind grid's focused row to a ModelView property. Here is our XAML,
<UserControl x:Class="OurProject.Silverlight.Views.Personnel.List"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" mc:Ignorable="d"
DataContext="{Binding Personnel, Source={StaticResource Locator}}"
d:DesignWidth="640" d:DesignHeight="480">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<dx:RiaInstantFeedbackDataSource x:Name="DataSource" QueryName="{Binding Path=QueryName}" KeyExpression="{Binding Path=KeyExpression}"
DomainContext="{Binding Path=Context}" />
<dxg:GridControl Name="grid" ItemsSource="{Binding ElementName=DataSource, Path=Data}" Grid.Row="0" AutoPopulateColumns="True" >
<dxg:GridControl.View>
<dxg:TableView x:Name="view" FocusedRow="{Binding Selected}" />
</dxg:GridControl.View>
</dxg:GridControl>
<Button Grid.Row="1" Height="30" VerticalAlignment="Bottom" Content="Edit" Command="{Binding Edit}" />
</Grid>
When we debug this code (breakpoint after Edit command executed) we realized that type of FocusedRow is object[]. We tried RowPropertyValueConverter but we can't find any document on how to use it. How can we bind selected row (or any property [for example Id column] from that row) to a property from ViewModel?
P.S: We checked this link, it does not work for RiaInstantDataSource.
Thanks in advance.
OK, we solved this issue with
AreSourceRowsThreadSafe="True"
addition to our code.
<dx:RiaInstantFeedbackDataSource x:Name="DataSource" QueryName="{Binding Path=QueryName}" KeyExpression="{Binding Path=KeyExpression}" AreSourceRowsThreadSafe="True" DomainContext="{Binding Path=Context}" />
We will trace the impacts of this with multi-threading and will write here back any important foundings.