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

Global Grid Style Breaks RowExpand/Collapse

1 Answer 47 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Andy asked on 31 Oct 2010, 06:47 PM
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

1 Answer, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 04 Nov 2010, 01:12 PM
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
Tags
TreeListView
Asked by
Andy
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Share this question
or