serhio
serhio

Reputation: 28586

WPF TopMost control

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 control as the TopMost in that control?

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

Upvotes: 3

Views: 4610

Answers (3)

serhio
serhio

Reputation: 28586

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

<line/>

<arrow/>
<textBlock/>

Upvotes: 1

brunnerh
brunnerh

Reputation: 184506

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.

Upvotes: 3

Dan Puzey
Dan Puzey

Reputation: 34198

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

b) No.

Upvotes: 2

Related Questions