代码之家  ›  专栏  ›  技术社区  ›  luvieere

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

  •  1
  • luvieere  · 技术社区  · 14 年前

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

    1 回复  |  直到 14 年前
        1
  •  1
  •   luvieere    14 年前

    绘制布局(网格、画布等),以便一个或多个单元格包含限制区域。然后在特定区域上绘制一个矩形或边框控件,以获得所需的效果。记得先添加矩形,或者像我在下面展示的那样使用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>