Silverlight 圆角

标签 silverlight silverlight-3.0

我有一个包含各种子元素的网格,例如网格、Stackpanel、图像...是否可以以裁剪所有内容的方式将网格的角变圆?此外,根网格的大小可能会有所不同,因此无法进行硬编码。

编辑:经过大量搜索,我发现这个问题的最佳解决方案是使用 @wdavo 所建议的 ClippingBehavior,谢谢!真正的问题是不知道图像的尺寸。如果您知道尺寸,那么就有许多简单的开箱即用解决方案。

最佳答案

您可以使用此剪辑行为

http://expressionblend.codeplex.com/SourceControl/changeset/view/61176#494852

您需要安装 Expression Blend SDK

<UserControl
x:Class="RoundedCorners.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:behaviors="clr-namespace:Expression.Samples.Interactivity"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
mc:Ignorable="d"
d:DesignHeight="800"
d:DesignWidth="800">
<Grid
    x:Name="LayoutRoot"
    Background="White"
    Margin="50">
    <Grid
        Background="LightGreen">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition
                Height="Auto" />
        </Grid.RowDefinitions>
        <i:Interaction.Behaviors>
            <behaviors:ClippingBehavior
                CornerRadius="30" />
        </i:Interaction.Behaviors>
        <Image
            Grid.Row="0"
            Stretch="Fill"
            Source="Image.JPG" />
        <StackPanel
            Grid.Row="1">
            <TextBlock
                Text="Hello" />
            <TextBlock
                Text="World" />
        </StackPanel>
    </Grid>
</Grid>

关于Silverlight 圆角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7757431/

相关文章:

silverlight - PixelFormats 和 WriteableBitmap.Lock 在 Silverlight3 中去了哪里?

c# - 中止请求 wp7

xaml - TextBox Binding TwoWay 在失去焦点之前不会更新 WP7

c# - 将 ARGB 拆分为字节值

collections - 在Silverlight 2中渲染 View 模型的异构集合

serialization - 如何调试逻辑删除的 WP7 应用程序中的序列化错误

c# - 网格绑定(bind)列名称

silverlight - WP7 : can't get img from httpget url using webclient. OpenReadAsync

xaml - 垂直放置 TabControl

silverlight - 有人在没有动画的 Silverlight 商业应用程序中使用无窗口模式吗?