Reputation: 35450
I'm trying to create a stylish window with icon in the top-right corner that is partly outside the window boundary. Since this is not directly possible (content falling outside the window is clipped), I'm using a Popup
control for it.
<Popup Placement="Right" HorizontalOffset="-80" VerticalOffset="-40" IsOpen="True" AllowsTransparency="True"
PlacementTarget="{Binding RelativeSource={RelativeSource AncestorType=Grid}}">
<Image Source="pack://application:,,,/graphics/AdminIcon.png" Stretch="None" />
</Popup>
It works fine, as long as I don't switch between windows. Thereupon it looks like the Popup is neither a proper child of the Window
, nor a fully separate window of its own; something in-between.
I'll try to explain it with two images:
Image1: Window loaded and popup showing nicely in the right-top corner:
Image2: ALT + TAB: Notepad somehow injects itself between Popup and Window
How do I solve this problem?
Upvotes: 0
Views: 385
Reputation: 128136
Instead of a Popup you may use a borderless, transparent Window:
<Window ...
WindowStyle="None" AllowsTransparency="True" Background="{x:Null}"
MouseLeftButtonDown="Window_MouseLeftButtonDown">
<Grid>
<Grid Margin="0,20,0,0" Background="White">
... window content goes here
</Grid>
<Image
Source="/graphics/AdminIcon.png" Stretch="None"
HorizontalAlignment="Right" VerticalAlignment="Top" />
</Grid>
</Window>
with this MouseLeftButtonDown
handler
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
DragMove();
}
and perhaps a close button somewhere.
Upvotes: 1