문제

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.

도움이 되었습니까?

해결책

I don't think there's a way to draw outside the bounds of a window. However, you could simply create a new window for the note control and align it to your main window.

다른 팁

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>

Contents of window will always get clipped. So basically there is only one way to go here. You could get the desired effect by creating a new transparent window for your floating content and then manualy set and update the position of floating content window based on the location of main window.

So far I've been using AvalonDock for similar functionalty. You might give it a try...

Did you try ClipToBounds property?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top