This is a migrated thread and some comments may be shown as answers.

Bind selected Grid rows

3 Answers 155 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Alexey
Top achievements
Rank 2
Alexey asked on 09 Jul 2009, 11:10 AM
Hi,

I want to bind selected rows from our viewmodel.

To do it in RadTreeView I added ContainerBindings to HierarchicalDataTemplate that binds IsSelected property of RadTreeViewItem.

How can I achieve this in RadGridView? I failed to find a way to add ContainerBindings to GridViewRow.

Thanks,
Alexey Zakharov.

3 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 15 Jul 2009, 05:55 AM
Hello Alexey,

The most common scenario is to bind the IsSelected property of our GridViewRow to the selection property of your View model classes. Unfortunately such binding is not possible prior Q2. If you try our latest relase you will be able to create container bindings.

I am sending you a sample project that demonstrates how you can bind the IsSelected property of GridViewRow in code.

Greetings,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Alexey
Top achievements
Rank 2
answered on 15 Jul 2009, 06:27 AM
Hi Milan,

But can I achieve this without codebehind?

PS : We are using Q2 last build for Silverlight 3.

Thanks,
Alexey Zakharov.
0
Milan
Telerik team
answered on 15 Jul 2009, 12:20 PM
Hi Alexey,

Such bindings are a not as straightforward to implement in SL as oposed to WPF but with a little bit of work you can bind the IsSelected property in XAML. I have modified the original sample application and you can now create bindings like this:

<Grid x:Name="LayoutRoot" Background="White">  
    <Grid.Resources> 
        <Style x:Key="CustomRowStyle" TargetType="grid:GridViewRow">  
            <Setter Property="local:IsSelectedBinding.PropertyName" Value="Selected"/>  
        </Style> 
    </Grid.Resources> 
    <telerikGrid:RadGridView Name="RadGridView1" RowStyle="{StaticResource CustomRowStyle}">  
    </telerikGrid:RadGridView> 
</Grid> 

You just have to create a new style for GridViewRow and set one attachable property. After that just apply the new style using the RowStyle property of RadGridView.



All the best,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Alexey
Top achievements
Rank 2
Answers by
Milan
Telerik team
Alexey
Top achievements
Rank 2
Share this question
or