blurred opacity

白昼怎懂夜的黑 提交于 2019-11-30 03:39:15

A VisualBrush can be used to get close to what you want, but has some limitations.

As long as you only need the glass effect within the window (and not be an effect over other windows) and that the placement of the glass effect border is controlled tightly then you could you something like this:-

  <Grid>
    <Border x:Name="src" Background="Silver">
      <Label HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="50">Hello World</Label>
    </Border>
    <Border Background="White" Margin="40" >
      <Border Opacity="0.5" >
          <Border.Effect>
            <BlurEffect Radius="10"/>
          </Border.Effect>
        <Border.Background>
          <VisualBrush  Visual="{Binding ElementName=src}" Stretch="None" />
        </Border.Background>
      </Border>
    </Border>
  </Grid>

I don't think that a child element within the visual tree is able to get the VisualBrush of it's parent so this might be a limitation for you. (i.e. the glass panel cannot be contained by the background panel)

I've used VisualBrushes many times usually with TranslateTransforms to move them around a bit to get the right image in the right place.

Update:

Altered XAML to use Effect and not BitmapEffect that is slower and now depreciated as mentioned in the comments below by Steven Robbins.

I would imagine you will need use an Effect for this, applied to a background rectangle or grid.

There's a decent library of effects here if that floats your boat.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!