Bind selected Grid rows

4 posts, 0 answers
  1. Alexey
    Alexey avatar
    79 posts
    Member since:
    Oct 2008

    Posted 09 Jul 2009 Link to this post

    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.
  2. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 15 Jul 2009 Link to this post

    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.
  3. DevCraft banner
  4. Alexey
    Alexey avatar
    79 posts
    Member since:
    Oct 2008

    Posted 15 Jul 2009 Link to this post

    Hi Milan,

    But can I achieve this without codebehind?

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

    Thanks,
    Alexey Zakharov.
  5. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 15 Jul 2009 Link to this post

    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.
Back to Top