Displaying wpf content over/outside main window bounds

Dale picture Dale · Jun 18, 2012 · Viewed 8.4k times · Source

I am trying to achieve an effect of overlapping the main window boundary with a control. It's hard to explain this in words which is also maybe why I am having difficulty finding information on how to do this or if it is even possible.

Below is an example of the effect I am trying to get (from the designer), where the "note" objects float outside the bounds of the main window.

Example 1

However the effect I get at runtime is this (below), the inner controls are clipped by the boundary of the main window.

Example 2

Can someone please tell me if this is possible (or not), and if it is maybe some suggestions about how I could get this effect.

Answer

Juzailie picture Juzailie · Aug 14, 2014

There is a control that can achieve this kind a behavior have you tried a Popup control? Check this out

Here's an examp;e"

<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>