MaterialDesign:从代码隐藏访问和更改 ShadowDepth

MaterialDesign: access and change ShadowDepth from code-behind

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

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

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

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

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

或者因为它是 an attached DP:

ShadowAssist.SetShadowDepth(btnUserAdd, ShadowDepth.Depth2);