开发者

Take element from Resources more than once in XAML

I have some elements of type Path in XAML UserControl r开发者_如何学编程esources, when I try to use some element more than once (for example in two different StackPanels) I get an InvalidOperationException.

What's the problem? Why resource element identifies as real component on my control?


Only Freezable objects that are frozen can be used more than once in the same visual tree. Path objects are not Freezable objects but FrameworkElement objects, hence the error. You can try using the x:Shared="False" attribute on the Path resource to create a new copy each time the resource is accessed to prevent the exception.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜