开发者

Silverlight - Bring Popup to Front

I have 4 popups, defined like this:

        <Popup x:Name="MyPopup1" IsOpen="True" Margin="0,10,0,0" Grid.Row="0" >
            <Popup.Child>
                <Thumb x:Name="thumb1" DragDelta="Thumb_DragDelta" Width="0" Height="0" Template="{StaticResource thumbDisplay}" />
            </Popup.Child>
        </Popup>
        <Popup x:Name="MyPopup2" IsOpen="True" Margin="0,20,0,0" Grid.Row="0" >
            <Popup.Child>
                <Thumb x:Name="thumb2" DragDelta="Thumb_DragDelta" Width="0" Height="0" Template="{StaticResource thumbDisplay}" />
            </Popup.Child>
        </Popup>

The template for the Thumb is just a user control. Since the Popups are a开发者_开发技巧lready open, I animate the contained thumb to size up when I need to show them to the user.

The problem is, when the user clicks on the thumb to drag it around, I'd really like to be able to bring it to front, so it's the top most control - just like regular popup windows work.

I have implemented the leftMouseDown event (in the usercontrol template of the Thumb), and tried both of the following (the second one to see if ANYTHING would work)

        Canvas.SetZIndex(this, 9999);

        Canvas.SetZIndex(VisualTreeHelper.GetOpenPopups().ElementAt(1), 9999);

(I also tried setting the Z-Index to 0 - to try and push a popup to the bottom, just, again, to see if anything would work) Nothing has worked in the least.

I've also tried what's here, also to no avail, though I suspect this doesn't apply to me since I don't have a ContentPResenter

Bring element forward (Z Index) in Silverlight/WPF


Again in case anyone searches for this, it looks like you can bring a popup to the front by resetting its IsOpen property. So just figure out which popup the control you're clicking belongs to, then just call this, and the popup will be on top again.

    private void FlashPopup(Popup popup) {
        popup.IsOpen = false;
        popup.IsOpen = true;
    }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜