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

时间:2010-06-22 12:49:07

标签: wpf shader pixel-shader bitmapeffect

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

1 个答案:

答案 0 :(得分:1)

绘制布局(网格,画布等),以便一个或多个单元格包含限制区域。然后在该特定区域绘制一个矩形或边框控件,以获得您想要的效果。请记住首先添加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>