Search code examples
c#wpftelerikradgridviewraddatapager

Telerik RadGridView + Style + RadDataPager = Cannot find source for binding IsPinned


Hello SO community :o)

First of all, I am sorry for my english, I know this is not perfect, but I break my back to improve it. :)

I am currently working with the telerik Framework in WPF.

Here is the code (I had to change my variables name)

 <telerik:RadGridView Name="GridName" IsPropertyChangedAggregationEnabled="True" EnableColumnGroupsVirtualization="True" EnableColumnVirtualization="True" ItemsSource="{Binding PagedSource, ElementName=PagerName}" AutoGenerateColumns="False" IsBusy="{Binding IsLoading}" SelectedItem="{Binding SelectedIsinFromGrid}" Grid.Row="0">
                <telerik:RadGridView.Resources>
                    <Style TargetType="{x:Type telerik:GridViewRow}" BasedOn="{StaticResource {x:Type telerik:GridViewRow}}" >
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Status}" Value="ACTIVE">
                                <Setter Property="Background" Value="{StaticResource GreenRessourceColor}" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding Status}" Value="DISABLE">
                                <Setter Property="Background" Value="{StaticResource RedRessourceColor}" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding Status}" Value="UNKNOW">
                                <Setter Property="Background" Value="{StaticResource YellowRessourceColor}" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </telerik:RadGridView.Resources>
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn Header="Header1" DataMemberBinding="{Binding Item1}" />
                    <telerik:GridViewDataColumn Header="Header2" DataMemberBinding="{Binding Item2}"/>
                    <telerik:GridViewDataColumn Header="Header3" DataMemberBinding="{Binding Item3}"/>
                    <telerik:GridViewDataColumn Header="Header4" DataMemberBinding="{Binding Status}"/>
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
            <telerik:RadDataPager Name="PagerName" Style="{StaticResource CustomDataPagerStyle}" Grid.Row="1" Source="{Binding ItemsListToDisplay}" PageSize="100" IsTotalItemCountFixed="False" />

The error:

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Telerik.Windows.Controls.GridView.GridViewRow', AncestorLevel='1''. BindingExpression:Path=IsPinned; DataItem=null; target element is 'GridViewPinButton' (Name=''); target property is 'IsPinned' (type 'Boolean')

The grid, the pager and the datas are well displayed with the right color, excepte that I have this error inside my VS output.

More information about the usage of this code.

This code is used inside a UserControl, this userControl is wrapped inside a RadPane then it is injected into a RadPaneGroup.

Why am I doing this? Because I am using prism to inject my modules on the fly into the mainRegion as a RadPane

The error occure only when I am moving the pane outside the RadPaneGroup

It is like I messed up with the RadGridView styleRow.

As you can see, I am not using directly the IsPinned property.

Any Idea?


Solution

  • I asked the same question on telerik forums.

    the short answer is : set your RadGridView's GroupRenderMode to Flat

    More details:

    The logged this question as a Telerik UI WPF bug.

    To get more information and code on this bug and how to reproduice it follow this link : Telerik Forum Binding error thread

    To follow the bug report : Bug report

    The answer made by telerik employ is:

    I was able to successfully reproduce the error at my end and have thus logged a new bug report in our feedback portal to which you can subscribe in order to get notified about any changes in its status. As a gratitude for your help, I've awarded you with some Telerik points.

    For the time being, you can set your RadGridView's GroupRenderMode to Flat in order to avoid these binding errors.

    Regards, Dilyan Traykov Telerik by Progress