开发者

Wpf show items over control

开发者 https://www.devze.com 2023-02-11 08:02 出处:网络
I need to create control wich can show items over itself (just dont clip them if there is no space) All textblocks added to grid开发者_运维技巧. Grid and control has property ClipToBounds = false.

I need to create control wich can show items over itself (just dont clip them if there is no space)

Wpf show items over control

All textblocks added to grid开发者_运维技巧. Grid and control has property ClipToBounds = false. Why items clipped by control in my case?

   <Style TargetType="{x:Type local:SomeControl}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:SomeControl}">
                <!-- Root Grid-->
                <Grid x:Name="LayoutRoot"
                      Background="{TemplateBinding Background}">
                    <Grid x:Name="TicksHolder"
                          ClipToBounds="False"
                          Background="Transparent" >
                 <!-- Items Dynamically added here-->
                    </Grid>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

And as you can see from image only right border clips items. rectangles out of right border doesnot clipped!

I found how to reproduce with more simple code:

      <Grid HorizontalAlignment="Left" Height="112" VerticalAlignment="Top" Width="52">
                <TextBlock TextWrapping="Wrap" Text="TextBlock" Width="78" Margin="37,0,0,0"/>
            </Grid>

And also i noticed that Grid clips content and Canvas is not


ClipToBounds property

http://msdn.microsoft.com/en-us/library/system.windows.uielement.cliptobounds.aspx


I Think that only one way out is to use Canvas instead of grid

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号