本文介绍了x:Shared = false 默认的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以默认设置 x:Shared = false ?我有很多ResourceDictionary,我经常在添加新项目时忘记设置它,只能在运行时发现.

Is it possible to set x:Shared = false by default somehow? I have many ResourceDictionary and I often forget to set it when adding new item, which can only be discovered at run-time.

补充问题:

为什么 x:Shared 永远不会被智能感知显示?有没有办法解决这个问题?

Why x:Shared is never shown by intellisense? Is there a way to fix this?

推荐答案

不,这是不可能的,因为 x:Shared 仅用于 XAML.没有等效的代码可以在 C# 代码中设置它,否则您可以通过创建附加属性来解决问题.

No, it is not possibility, because x:Shared is used in XAML only. There is no code equivalent to set it in C# code, otherwise you could have solved the problem by creating an attached property.

这篇关于x:Shared = false 默认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 17:52