MaterialDesign:从代码后台访问和更改ShadowDepth

时间:2019-11-27 09:20:16

标签: c# wpf xaml material-design-in-xaml

我可以使用以下xaml代码在materialDesign中创建Card:

<materialDesign:Card materialDesign:ShadowAssist.ShadowDepth="Depth1" x:Name="btnUserAdd">
</materialDesign:Card>

如何在下面的代码中将“ ShadowDepth”更改为“ Depth2”?

1 个答案:

答案 0 :(得分:0)

像其他任何依赖项属性一样:

btnUserAdd.SetValue(ShadowAssist.ShadowDepthProperty, ShadowDepth.Depth2);

或者因为它是an attached DP

ShadowAssist.SetShadowDepth(btnUserAdd, ShadowDepth.Depth2);