GroupRenderMode="Flat" and style binding errors

5 posts, 0 answers
  1. Louis
    Louis avatar
    83 posts
    Member since:
    Aug 2013

    Posted 17 Mar 2014 Link to this post

    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;
        }
    }
  2. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 20 Mar 2014 Link to this post

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Technique
    Technique avatar
    11 posts
    Member since:
    Nov 2011

    Posted 20 Mar 2014 Link to this post

    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,






  5. Technique
    Technique avatar
    11 posts
    Member since:
    Nov 2011

    Posted 20 Mar 2014 in reply to Technique Link to this post

    I also noticed that it works if StatusCode is a string, but it did not when it's a int
  6. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 25 Mar 2014 Link to this post

    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.

     
Back to Top
UI for WPF is Visual Studio 2017 Ready