开发者

WPF TopMost control

开发者 https://www.devze.com 2023-02-22 11:11 出处:网络
I have the following UserControl <UserControl x:Class=\"MyControl\"> <Canvas Background=\"Transparent\">

I have the following UserControl

<UserControl x:Class="MyControl">
    <Canvas Background="Transparent">
        <Line x:Name="line"/>
        <TextBlock x:Name="textBlock" Panel.ZIndex="99999999" />
        <Polygon Name="arrow" "/>
    </Canvas>
</UserControl>

a) Is the Panel.ZIndex="99999999" a correct way to set this cont开发者_如何学Gorol as the TopMost in that control?

b) Will it change if I switch the visibility (Visible=>Invisible=>Visible) ?


a) That is quite unclean, i'd suggest you add the system namespace

xmlns:sys="clr-namespace:System;assembly=mscorlib"

And set it like this:

Panel.ZIndex="{x:Static sys:Int32.MaxValue}"

b) That should have no effect.


a) Yes, though setting it to 1 would usually be sufficient.

b) No.


an other option is just to change the order of elements in the node

<line/>

<arrow/>
<textBlock/>
0

精彩评论

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