none
WPF 窗体圆角问题 RRS feed

  • 问题

  • 根据需求窗体里 只有一个tabcontrol  

    tabitem里 Content 是一个UserControl  

    如果用<Border CornerRadius="5,5,5,5" Background="#1771d0">做圆角,会直接给UserControl遮盖,请问还有什么好的办法。

    2017年4月11日 7:08

答案


  • Hi 没事养个哈土奇,

    根据你的描述,我尝试了下面的代码。希望对你有帮助。

     <Grid Background="Transparent">
            <TabControl >
                <TabItem>
                    <Border  Name="top" BorderThickness="2" BorderBrush="DarkGreen"  SizeChanged="top_SizeChanged">
                        <Grid>
                            <local:CalendarMatrixusercontrol HorizontalAlignment="Left"  VerticalAlignment="Top"/>
                        </Grid>
                    </Border>
                </TabItem>
            </TabControl>
        </Grid>
    
           private void top_SizeChanged(object sender, SizeChangedEventArgs e)
            {
                System.Windows.Rect r = new System.Windows.Rect(e.NewSize);
                RectangleGeometry gm = new RectangleGeometry(r, 10, 10); // 40 is radius here
                ((UIElement)sender).Clip = gm;
            }
    
    


    >>会直接给UserControl遮盖

    你也可以尝试设置相对位置来避免。


    Best Regards,

    Yohann Lu


    MSDN Community Support<br/> Please remember to click &quot;Mark as Answer&quot; the responses that resolved your issue, and to click &quot;Unmark as Answer&quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact <a href="mailto:MSDNFSF@microsoft.com">MSDNFSF@microsoft.com</a>.

    2017年4月12日 5:40
    版主