0

Here is my treeview code :

<TreeView Name="UIListAddedTaches" Grid.Column="2" Grid.RowSpan="5" Background="#FFE4E4E4" Foreground="Gray">
        <TreeView.ItemContainerStyle>
            <Style TargetType="{x:Type TreeViewItem}">
                <Setter Property="SnapsToDevicePixels" Value="True"/>
                <Setter Property="BorderThickness" Value="1"/>
                <!--working style-->

                <!--When skip this 'template' setter , the data are displayed-->
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type TreeViewItem}">
                            <Border Name="Border" CornerRadius="1" BorderThickness="1">
                                <Border.BorderBrush>
                                    <SolidColorBrush Color="Red"/>
                                </Border.BorderBrush>
                                <Border.Background>
                                    <SolidColorBrush Color="Green" Opacity="0.5" />
                                </Border.Background>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </TreeView.ItemContainerStyle>

        <TreeView.ItemTemplate>
            <DataTemplate>
                <Canvas>
                    <TextBlock Canvas.Bottom="-20" Canvas.Left="570" FontWeight="Bold" Text="{Binding UserID}">
                        <TextBlock.ToolTip>
                            <ToolTip  Content="{Binding Author}" ContentStringFormat="{}Auteur : {0}" />
                        </TextBlock.ToolTip>
                    </TextBlock>
                    <!--...-->
                </Canvas>
            </DataTemplate>
        </TreeView.ItemTemplate>
    </TreeView>

The problem comes cause of the "Template" setter. When I put this style setter, the data are "hidden" by the background : even with the opacity. Datas are still in the list. Doing this in this way in this exemple is overkill but i need to do it like that to apply conditionnal triggers and stuff. A solution to get datas AND template prop ?

  • you are missing `` inside Template – ASh Oct 30 '17 at 10:30
  • Like that ? ``` ``` Still the same behaviour –  Oct 30 '17 at 10:39
  • study a default TreeViewItem template using approach described [here](https://stackoverflow.com/questions/8825030/how-to-extract-default-control-template-in-visual-studio). it will give an idea what else is missing (ItemsPresenter) – ASh Oct 30 '17 at 10:46
  • It is not the problem. If it was, i wouldnt have the data in my Collection. The problems comes form the displaying. –  Oct 30 '17 at 10:55

0 Answers0