Setting GridViewRow.IsPinned through style

4 posts, 0 answers
  1. Christian
    Christian avatar
    4 posts
    Member since:
    Sep 2012

    Posted 15 Dec 2016 Link to this post

    Hi

    I'm trying to data-bind the IsPinned-property of the GridViewRow to a value from my model.

    After numerous unsuccessful tries, I tried setting the IsPinned property to true through a style (see below).

    However, the row is not pinned, also the button does not reflect the Pinned state.

    How can I set the IsPinned-property through a property of my model?

     

    01.<telerik:RadGridView Grid.Row="2" ItemsSource="{Binding Path=CalculablePersons}" GroupRenderMode="Flat" PinnedRowsPosition="Top">
    02.    <telerik:RadGridView.Resources>
    03.        <Style TargetType="{x:Type telerik:GridViewRow}" BasedOn="{StaticResource {x:Type telerik:GridViewRow}}">
    04.            <Setter Property="IsPinned" Value="True" />
    05.        </Style>
    06.    </telerik:RadGridView.Resources>
    07. 
    08.    <telerik:RadGridView.Columns>
    09.        <telerik:GridViewPinRowColumn />
    10.        <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Path=Name}" />
    11.    </telerik:RadGridView.Columns>
    12.</telerik:RadGridView>
  2. Stefan
    Admin
    Stefan avatar
    1073 posts

    Posted 19 Dec 2016 Link to this post

    Hello Christian,

    This requirement can be achieved through the usage of the TogglePinnedRowState ICommand. Please, take a look at the Commands section of the Pinner Rows topic.

    Hopefully, this helps.

    Regards,
    Stefan X1
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Christian
    Christian avatar
    4 posts
    Member since:
    Sep 2012

    Posted 19 Dec 2016 in reply to Stefan Link to this post

    Hello Stefan

    I'm sorry, but this is not the solution I'm looking for. The TogglePinnedRowState command cannot be bound to a boolean property through a style.

    The above style that I posted would accomplish exactly what I need, however, the IsPinned property is not pinning rows, only the command does.

    I think this is a bug that needs to be fixed, because the IsPinned property is not marked as read-only, I would expect that the above style works.

  4. Stefan
    Admin
    Stefan avatar
    1073 posts

    Posted 22 Dec 2016 Link to this post

    Hello Christian,

    The IsPinned property of GridViewRow is actually not meant to be set externally. It is internally bound to the Button through which the user pins a given row through the UI. As stated in my previous reply, the built-in mechanism for such requirement is to utilize the TogglePinnedRowState ICommand.

    Regards,
    Stefan X1
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top