开发者

Panel.ZIndex property in a treeviewitem in wpf

I Wish the treeviewitem to overlap the other items when i mouse hover it.

To do this i made the parent element (in my case its Border) within the HierarchicalDataTemplate to have the ZIndex as 0 and changed this value to 1 when the us开发者_开发百科er hovers the mouse in the HierarchicalDataTemplate.Triggers section

<HierarchicalDataTemplate  DataType="{x:Type d:MyClass}">
    <Border Name="brd" CornerRadius="5" BorderThickness="1" Padding="3" Margin="0,0,60,0" Panel.ZIndex="0" >
        <StackPanel Orientation="Horizontal" Margin="0,0,0,0" > 

            <Image Source="../Images/icon.jpg"  Height="30"></Image>

            <TextBlock TextAlignment="Center" Text="{Binding Text}" 
                   Margin="3,0,10,0" >
            </TextBlock>  

            <Image Margin="0,0,3,0" 
                   Source="../Images/Img1.jpg" Height="30" />

            <Image Margin="0,0,0,0" 
                   Source="../Images/Img2" Height="30"/>
        </StackPanel>
    </Border>
    <HierarchicalDataTemplate.Triggers>
        <Trigger SourceName="brd" Property="IsMouseOver" Value="True">
            <Setter TargetName="brd" Property="Panel.ZIndex" Value="1"></Setter>
        </Trigger>            
    </HierarchicalDataTemplate.Triggers>
</HierarchicalDataTemplate>

The whole idea to implement this was:

Whenever the user hovers the mouse over a treeviewitem, the item should overlap the other controls and should be completely visible. Example: if the item is a long text, then the user should not be forced to use the scroll bar, rather if he just points it the item should be overlapping the other controls to display the complete item.

But i couldn't achieve this using the above triggers.

Please help me doing this.


Did you try using a ToolTip? I didn't try it myself but after seeing this I'm convinced that it's possible to define a DataTemplate which can be used at this property so the item is shown the way you like.

I hope this helps.

Regards

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜