Global Grid Style Breaks RowExpand/Collapse

2 posts, 0 answers
  1. Andy
    Andy avatar
    3 posts
    Member since:
    Aug 2010

    Posted 31 Oct 2010 Link to this post

    Having this style defined in app.xaml...

    <Style TargetType="Grid">
        <Setter Property="Background" Value="#00000000" />
    </Style>

    .. breaks the TreeListView expand/collapse behaviour.  This breaks regardless of the value of the Background.  This was an extremely time consuming and frustrating bug to track down.


    Full sample:

    MainWindow.xaml
    <Window x:Class="TreeListViewExample.MainWindow"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView" Title="MainWindow" Height="350" Width="525">
        <Grid>
            <Controls:RadTreeListView ItemsSource="{Binding Items}" AutoGenerateColumns="False">
                <Controls:RadTreeListView.ChildTableDefinitions>
                    <Controls:TreeListViewTableDefinition ItemsSource="{Binding Children}"/>
                </Controls:RadTreeListView.ChildTableDefinitions>
                <Controls:RadTreeListView.Columns>
                    <Controls:GridViewDataColumn Header="Test" DataMemberBinding="{Binding Text}"/>
                </Controls:RadTreeListView.Columns>
            </Controls:RadTreeListView>
        </Grid>
    </Window>

    App.xaml
    <Application x:Class="TreeListViewExample.App"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 StartupUri="MainWindow.xaml">
        <Application.Resources>
            <Style TargetType="Grid">
                <Setter Property="Background" Value="Green"/>
            </Style>
        </Application.Resources>
    </Application>


    Codebehind:
    public partial class MainWindow : Window
    {
       public MainWindow()
       {
          InitializeComponent();
          DataContext = this;
     
          Items = new ObservableCollection<TestClass>();
          var child3 = new TestClass {Text = "child 3"};
          var child2 = new TestClass {Text = "child 2", Children = new[] {child3}};
     
          var child = new TestClass {Text = "child", Children = new[] {child2}};
          Items.Add(child);
       }
     
       public ObservableCollection<TestClass> Items { get; private set; }
    }
     
    public class TestClass
    {
       public string Text { get; set; }
       public IEnumerable<TestClass> Children { get; set; }
    }


    Cheers,

    Andy
  2. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 04 Nov 2010 Link to this post

    Hi Andy,


    Generally it is not a good practice to create an implicit style for the Grid that acts as a layout container in your application. If you take a look at the template of RadTreeListView you will see that a number of Grids are used and when you create such global style, it is applied to all of them, and thinking in this way this is not recommended approach. If you want to maintain this style just make it explicit instead of implicit and set it as a DynamicResource to your LayoutRoot.


    Greetings,
    Vanya Pavlova
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top