1

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

4

1 回答 1

1

绘制布局(网格、画布等),使一个或多个单元格包含限制区域。然后在该特定区域上绘制一个 Rectangle 或 Border 控件以获得所需的效果。请记住首先添加 Rectangle,或者使用 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>
于 2010-08-16T12:36:08.813 回答