Hierarchy column background

1 posts, 0 answers
  1. Arman
    Arman avatar
    1 posts
    Member since:
    Feb 2013

    Posted 03 Jun 2013 Link to this post

     Hi!

    How can i draw left area in hierarchical cells same as hierarchical cell background?

    <UserControl.Resources>
          <Style TargetType="telerik:GridViewRow" x:Name="style1">
              <Setter Property="Background">
                  <Setter.Value>
                      <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                          <GradientStop Color="#882222FF" />
                          <GradientStop Color="#88CCCCCC" Offset="1"/>
                      </LinearGradientBrush>
                  </Setter.Value>
              </Setter>
          </Style>
          <Style TargetType="telerik:GridViewRow" x:Name="style2">
              <Setter Property="Background">
                  <Setter.Value>
                      <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                          <GradientStop Color="#44777777" />
                          <GradientStop Color="#44DDDDDD" Offset="1"/>
                      </LinearGradientBrush>
                  </Setter.Value>
              </Setter>
          </Style>
          <Style TargetType="telerik:GridViewRow" x:Name="style3">
              <Setter Property="Background" Value="White" />
          </Style>
     
      </UserControl.Resources>
     
      <Grid x:Name="LayoutRoot">
          <telerik:RadTreeListView HorizontalAlignment="Stretch" Name="radTreeListView1" VerticalAlignment="Stretch"
                                   AutoGenerateColumns="False"
                                   ShowColumnFooters="True"
                                   RowIndicatorVisibility="Collapsed"
                                   FrozenColumnsSplitterVisibility="Collapsed"
                                   IsExpandedBinding="{Binding IsExpanded, Mode=TwoWay}"
                                   FrozenColumnCount="1"
                                   >
              <telerik:RadTreeListView.ChildTableDefinitions>
                  <telerik:TreeListViewTableDefinition ItemsSource="{Binding Items, Mode=TwoWay}"/>
              </telerik:RadTreeListView.ChildTableDefinitions>
     
              <telerik:RadTreeListView.Columns>
                  <telerik:GridViewDataColumn DataMemberBinding="{Binding ObjectName}" Background="Beige"/>
                  <telerik:GridViewDataColumn DataMemberBinding="{Binding Params[\RIG\] }"  />
                  <telerik:GridViewDataColumn DataMemberBinding="{Binding Params[\BOREHOLE\]}"  />
                  <telerik:GridViewDataColumn DataMemberBinding="{Binding Params[\VALUE\]}"  />
                  <telerik:GridViewDataColumn DataMemberBinding="{Binding Params[\VALUE2\]}"  />
                  <telerik:GridViewDataColumn DataMemberBinding="{Binding Params[\VALUE3\]}"  />
              </telerik:RadTreeListView.Columns>
          </telerik:RadTreeListView>
     
      </Grid>



    ObservableCollection<MyStruct> _hierarchyRelations = new ObservableCollection<MyStruct>(); 
     private class HierarchyObjectRowStyle : StyleSelector
    {
        public HierarchyObjectRowStyle()
        {
            Styles = new ObservableCollection<Style>();
        }
     
        public override Style SelectStyle(object item, DependencyObject container)
        {
            if (item is GridHierarchyItem)
            {
                GridHierarchyItem node = item as GridHierarchyItem;
                if (node.Level < Styles.Count && node.Items != null && node.Items.Count != 0)
                {
                    return Styles[node.Level];
                }
                if (Styles.Count > 0)
                {
                    return Styles[Styles.Count - 1];
                }
            }
            return null;
        }
        public ObservableCollection<Style> Styles { get; set; }
    }
     
    public MainPage()
    {
        InitializeComponent();
        var data = new MyStruct();
        data.GetRandomData();
        var rowStyle = new HierarchyObjectRowStyle();
        rowStyle.Styles = new ObservableCollection<Style>();
        rowStyle.Styles.Add((Style)this.Resources["style1"]);
        rowStyle.Styles.Add((Style)this.Resources["style2"]);
        rowStyle.Styles.Add((Style)this.Resources["style3"]);
        radTreeListView1.RowStyleSelector = rowStyle;
        radTreeListView1.ItemsSource = data;

    }


    Regards
    Arman,


Back to Top