Reputation: 24919
So, i have all of my controls nicely laid out using grids and stack panels.
In some cases, i would like to show a dialog layer (to add preferences etc). It does not need to be modal, and it does not need to have transparent background.. i just need it to be nice, unobtrusive, and positioned absolutely..
the only way i can think of to position such dialog control absolutely, is using a canvas, which i am not using. i need it to show on top of regularly laid out controls..
What are some options?
Upvotes: 0
Views: 1387
Reputation: 4885
I believe this is what you are looking for.... You can Place your control in your adorner and then by a change of a bool property you can show or hide it... you can customize the behaviour to your likes
Upvotes: 0
Reputation: 26352
I think what you are looking for is to set the Panel.ZIndex
to a high value for your Dialog. Then simply set the visibility to hide the dialog. http://msdn.microsoft.com/en-us/library/system.windows.controls.panel.zindex.aspx
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TextBlock Panel.ZIndex="9999" Background="Green">This TextBlock will always be on top as long as it is visible.</TextBlock>
<TextBlock Background="Red">Test</TextBlock>
</Grid>
</Window>
You can then combine this with the Dialog box in this example: WPF C# InputBox
Upvotes: 0
Reputation: 51329
You can either use a popup control (set the PlacementRectangle value to position the content) or the Adorner layer to do this. The adorner technique is described here: http://bignickolson.com/2009/10/15/overlaying-controls-in-wpf-with-adorners/
Upvotes: 2