Silverlight - Space between the top of the TreeView and the first TreeViewItem

I have a question related to This .

How can you change the spacing between the top of the TreeView control and the first TreeViewItem? Specifically, I want to REDUCE the space between the top of the control and the first item. As with the other question, I am guessing that I will need to redo the TreeView. But what style do I need for chnage and what property controls this particular space?

Thanks in advance.

+1


a source to share


2 answers


I got my question about Silverlight answered, net forums here . Essentially I needed to add a control template and change the field to ItemPresenter.



<ctl:TreeView>
  <ctl:TreeView.Template>
    <ControlTemplate TargetType="ctl:TreeView">
      <Grid x:Name="Root" >
        <Grid.Resources>
          <SolidColorBrush x:Key="BorderBrush" Color="#FF000000" />
        </Grid.Resources>
        <Border x:Name="Border" BorderBrush="{StaticResource BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2">
          <Border Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}" Margin="1">
            <ScrollViewer x:Name="ScrollViewer" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Background="{x:Null}" BorderBrush="Transparent" BorderThickness="0" IsTabStop="False" TabNavigation="Once">
              <ItemsPresenter x:Name="TreeItems" Margin="5" />
            </ScrollViewer>
          </Border>
        </Border>
      </Grid>
    </ControlTemplate>
  </ctl:TreeView.Template>
<ctl:TreeView>

      

+1


a source


You can use addon for TreeView:

<TreeView Name="treeView1" Padding="0,50,0,0 ">
            <TreeViewItem Header="test" Selected="TreeViewItem_Selected">
                <TreeViewItem Header="sub test" />
            </TreeViewItem>
        </TreeView>

      



this will add 50 space to the top of the tree.

+1


a source







All Articles