Silverlight 4 边框剪辑

发布于 2024-09-25 00:25:03 字数 108 浏览 2 评论 0原文

Silverlight 4 中是否可以创建一个圆角边框来剪辑任何子 UI 元素?到目前为止,我尝试通过将按钮设置为边框控件的子元素来实现此目的,但是当我设置圆角半径以在边框中创建圆角时,按钮不会被剪切。

Is it possible in Silverlight 4 to create a border with rounded corners that clips any of it child UI Element? So far I have attempted to do so by setting a button as a child element of a border control but the buttons does not get clipped when I set the corner radius to create rounded corners in the border.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瑾兮 2024-10-02 00:25:03

查看 ClippingBehavior,它是 Expression Blend 示例的一部分代码丛。这是一种 Blend 行为,因此要添加它,您必须从 Blend SDK 引用 System.Windows.Interactivity.dll 并将该行为拖放到 Blend 中的元素上或将其添加到 XAML 中:

<UserControl x:Class="MyApplication.MainPage"
    ...other xmlns imports...
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:samples="clr-namespace:Expression.Samples.Interactivity;assembly=Expression.Samples.Interactivity"
    >

    <Border>
        <i:Interaction.Behaviors>
            <samples:ClippingBehavior CornerRadius="15"/>
        </i:Interaction.Behaviors>
        <!-- content to be clipped goes here -->
    </Border>
</UserControl>

这是添加圆角的简单且可重用的方法/clipping 到任何 UI 元素。

Take a look at the ClippingBehavior that is part of the Expression Blend Samples on CodePlex. It's a Blend behavior, so to add it you have to reference System.Windows.Interactivity.dll from the Blend SDK and drop the behavior on the element in Blend or add it in XAML:

<UserControl x:Class="MyApplication.MainPage"
    ...other xmlns imports...
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:samples="clr-namespace:Expression.Samples.Interactivity;assembly=Expression.Samples.Interactivity"
    >

    <Border>
        <i:Interaction.Behaviors>
            <samples:ClippingBehavior CornerRadius="15"/>
        </i:Interaction.Behaviors>
        <!-- content to be clipped goes here -->
    </Border>
</UserControl>

This is a straightforward and reusable way to add rounded corners/clipping to any UI Element.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文