限制 WPF 着色器效果应用的区域

发布于 2024-09-06 10:30:34 字数 151 浏览 2 评论 0原文

如何限制应用 WPF 着色器效果的区域,其方式与过时的 BitmapEffectInput.AreaToApplyEffect 用于 BitmapEffects 的方式类似?着色器效果是否有等效的属性,或者我是否必须自己将其添加到我正在编写的每个着色器效果中?

How can I restrict the area that a WPF shader effect gets applied to, in a similar manner to the way the obsolete BitmapEffectInput.AreaToApplyEffect used to work for BitmapEffects? Is there an equivalent property for shader effects, or do I have to add it myself within each and every shader effect that I'm writing?

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

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

发布评论

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

评论(1

划一舟意中人 2024-09-13 10:30:34

绘制一个布局(网格、画布等),使一个或多个单元格包含受限区域。然后在该特定区域上绘制矩形或边框控件以获得您想要的效果。请记住首先添加矩形,或者使用 ZIndex,如下所示,这样您的代码就不会隐藏任何控件。

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition/>
        <RowDefinition/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition/>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>
    <Rectangle Grid.Column="0" Grid.Row="1" Panel.ZIndex="0" >
        <Rectangle.Style>
            <Style TargetType="{x:Type Rectangle}">
                <Setter Property="Fill" Value="Blue"/>
            </Style>
        </Rectangle.Style>
    </Rectangle >
    <TextBox Grid.Column="0" Grid.Row="1" Height="25" Margin="10" Text="Test 123" Panel.ZIndex="1" />
</Grid>

Draw a layout (Grid, Canvas etc.), so that one or more cells contain the restricted area. Then draw a Rectangle or Border control on that particular area to get the desired effect you are looking for. Remember to add the Rectangle first, or play with ZIndex as I show below so that your code does not hide any controls.

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition/>
        <RowDefinition/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition/>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>
    <Rectangle Grid.Column="0" Grid.Row="1" Panel.ZIndex="0" >
        <Rectangle.Style>
            <Style TargetType="{x:Type Rectangle}">
                <Setter Property="Fill" Value="Blue"/>
            </Style>
        </Rectangle.Style>
    </Rectangle >
    <TextBox Grid.Column="0" Grid.Row="1" Height="25" Margin="10" Text="Test 123" Panel.ZIndex="1" />
</Grid>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文