5) Change the Background property of the nested Borer Control from
Background="{TemplateBinding Background}"
to
Background="{DynamicResource BackgroundBrush}"
Now when you compile and use this control in any project, the background will NOT be yellow. BUT, if you change the background property to be a StaticResource as such
Background="{StaticResource BackgroundBrush}"
...it will work. Why is this? Why does StaticResource work but not DynamicResource???
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
如果您在 Xaml 文件中对画笔进行硬编码,那么对我来说这听起来相当静态。
DynamicResource 的 MSDN 条目说这是当您想要使用时使用的在运行时解析资源的名称(即该名称存储在另一个资源中),您在编译时就知道该名称。
听起来很像 C 中的指针和指向指针的指针。
If you are hard coding the brush in Xaml file, that sounds pretty static to me.
The MSDN entry for DynamicResource say this is for when you want the use resolve the name of the resource at run time (ie the name is stored in a another resource), where you know the name at compile time.
Sounds very much like a pointer verse a pointer-to-a-pointer from C.