Display wpf content on top / outside of the main window

I am trying to achieve the effect of overlapping the border of the main window using a control. It is difficult to explain this in words, which may also be due to the fact that it is difficult for me to find information on how to do this or if it is possible.

The following is an example of the effect I'm trying to get (from the designer), where the "note" objects are floating outside the main window.

Example 1

However, the effect that I get at runtime is this (below), the internal controls are clipped to the border of the main window.

Example 2

Can someone please tell me if this is possible (or not), and if possible some suggestions on how I can get this effect.

+6
source share
4 answers

I don’t think there is a way to draw outside the window. However, you can simply create a new window for recording management and bring it to the main window.

+1
source

There is a control that can achieve this kind of behavior if you try the Popup control
check out http://msdn.microsoft.com/en-us/library/bb613596(v=vs.110).aspx

I have an example for this

<Window x:Class="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> <ToggleButton x:Name="MainButton" Content="Show popup" VerticalAlignment="Top" HorizontalAlignment="Right"/> <Popup PlacementTarget="{Binding ElementName=MainButton}" Placement="Bottom" AllowsTransparency="True" IsOpen="{Binding ElementName=MainButton, Path=IsChecked}"> <Grid> <Border BorderBrush="Orange" BorderThickness="1" Background="Yellow"/> <TextBlock Text="Lorem Ipsum is simply dummy text of the printing and typesetting industry"/> </Grid> </Popup> </Grid> 

+5
source

The contents of the window will always be cropped. So basically there is only one way to go here. You can get the desired effect by creating a new transparent window for your floating content, and then manually set and update the position of the floating content window depending on the location of the main window.

So far I have used AvalonDock for similar functionality. You may try...

+2
source

Have you tried the ClipToBounds property?

0
source

Source: https://habr.com/ru/post/918332/


All Articles