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

GroupRenderMode="Flat" and style binding errors

4 Answers 92 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Louis
Top achievements
Rank 1
Louis asked on 17 Mar 2014, 05:43 PM
I am getting binding errors in the debug log when I use GroupRenderMode="Flat" with styles that depend on the ItemsSource item values. It looks as if each row is trying to bind to the RadGridView's DataContext in addition to the actual items. The style is applying correctly, the only difference I can see is the new errors in the debug log.

Below is a small example showing the problem. Note the binding error for every line in the grid:

System.Windows.Data Error: 40 : BindingExpression path error: 'IsComplete' property not found on 'object' ''MainWindow' (Name='')'. BindingExpression:Path=IsComplete; DataItem='MainWindow' (Name=''); target element is 'GridViewRow' (Name=''); target property is 'NoTarget' (type 'Object')

which does not occur if GroupRenderMode="Nested". It's trying to bind to MainWindow object instead of an Item.

Is this a bug or have I done something wrong somewhere?

Thanks,
Louis


<telerik:RadGridView ItemsSource="{Binding Path=Items}" AutoGenerateColumns="False" GroupRenderMode="Flat">
    <telerik:RadGridView.Resources>
        <Style TargetType="{x:Type telerik:GridViewRow}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=IsComplete}" Value="False">
                    <Setter Property="Background" Value="Red"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </telerik:RadGridView.Resources>
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn Header="ItemName" DataMemberBinding="{Binding Path=ItemName}" Width="*" />
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

public class Item
{
    public string ItemName { get; set; }
    public bool IsComplete { get; set; }
}
public partial class MainWindow : Window
{
    public ObservableCollection<Item> Items { get; set; }
    public MainWindow()
    {
        InitializeComponent();
        Items = new ObservableCollection<Item>();
        for (int i = 0; i < 5; i++)
            Items.Add(new Item()
            {
                ItemName = "Object " + i,
                IsComplete = (i % 2 == 1 ? true : false)
            });
        DataContext = this;
    }
}

4 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 20 Mar 2014, 07:55 AM
Hello Louis,

Thank you for reporting this.

I was able to reproduce this problem. I have logged the issue into our Feedback portal as a bug report. You can track its status: here.

Regards,
Yoan
Telerik
 

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

 
0
Technique
Top achievements
Rank 1
answered on 20 Mar 2014, 01:46 PM
I also have those binding errors when trying to apply a style on a GridViewRow

My style is defined like this :

    <Style x:Key="BsiDataRowConstat" TargetType="{x:Type GridView:GridViewRow}" >
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=StatusCode}" Value="02">
                <Setter Property="Foreground" Value="LimeGreen" />
                <Setter Property="FontWeight" Value="Normal" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=StatusCode}" Value="04">
                <Setter Property="Foreground" Value="DarkGray" />
                <Setter Property="FontWeight" Value="Normal" />
            </DataTrigger>
        </Style.Triggers>
    </Style>

And is used like this

<Telerik:RadGridView.Resources>
                    <Style TargetType="{x:Type telerik:GridViewRow}" BasedOn="{StaticResource BsiDataRowConstat}" />
</Telerik:RadGridView.Resources>

Regards,






0
Technique
Top achievements
Rank 1
answered on 20 Mar 2014, 05:27 PM
I also noticed that it works if StatusCode is a string, but it did not when it's a int
0
Yoan
Telerik team
answered on 25 Mar 2014, 07:30 AM
Hi Louis,

Thank you for this additional note. We will investigate the case, however I cannot commit to a certain time frame when this will be fixed. You can track the progress of the issue in our Feedback portal.

Regards,
Yoan
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
Tags
GridView
Asked by
Louis
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Technique
Top achievements
Rank 1
Share this question
or