Displaying wpf content over/outside main window bounds [closed]

坚强是说给别人听的谎言 提交于 2019-12-19 18:33:12

问题


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.

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

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.


回答1:


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.




回答2:


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>




回答3:


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




回答4:


Did you try ClipToBounds property?



来源:https://stackoverflow.com/questions/11078163/displaying-wpf-content-over-outside-main-window-bounds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!