Ian*_*Ian 1 wpf graphics xaml dropshadow
我已将效果应用于此模板的边框.然后效果会应用到其中的每个元素,因此我得到的阴影比我照顾的要多.有没有办法禁用这种效果?你可以看到我在里面添加了一个模糊效果,但后来我最终得到了模糊的阴影:)
DataTemplate x:Key="TestInstanceViewModelTemplate">
<Border BorderThickness="1" BorderBrush="#FF0909B4">
<Border.Effect>
<DropShadowEffect/>
</Border.Effect>
<DockPanel>
<DockPanel.Effect>
<BlurEffect/>
</DockPanel.Effect>
<Grid DockPanel.Dock="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="50" Width="1*" />
<ColumnDefinition MinWidth="50" Width="1*"/>
</Grid.ColumnDefinitions>
<Button Command="{Binding Path=StartCommand}" Content="Start" Grid.Column="0" Grid.Row="0" />
<Button Command="{Binding Path=StopCommand}" Content="Stop" Grid.Column="1" Grid.Row="0"/>
</Grid>
<WpfTestingClient:StatusControl DockPanel.Dock="Top" HorizontalAlignment="Stretch"></WpfTestingClient:StatusControl>
</DockPanel>
</Border>
</DataTemplate>
Run Code Online (Sandbox Code Playgroud)
我建议将最顶层的容器更改为Grid并在其中包含Border和DockPanel在同一级别上,让Border位于底部并伸展以填充Grid,同时将DockPanel放在顶部并在其周围添加1px边距说明你的BorderThickness.这种方式不仅将阴影仅应用于Border元素,而且每次内部发生任何变化时都不必重新渲染效果,从而节省了大量资源.
| 归档时间: |
|
| 查看次数: |
3446 次 |
| 最近记录: |