英文:
What elements can block WPF dependency property inheritance?
问题
我的WPF应用程序将一个自定义继承的依赖属性(来自行为)附加到我的主应用程序视图上。想法是将这个属性(一旦应用程序运行,就不会改变)传递到一些非常嵌套的需要它的控件中。
<Window x:Class="MyApp.Views.MainWindow"
core:SystemBehavior.SystemService="{Binding MySystem}"
它运行得很好。到目前为止,我的所有控件都能访问这个数据。
<ComboBox ItemsSource="{Binding RelativeSource={RelativeSource Self},
Path=(core:SystemBehavior.SystemService).Units}"
但在MS关于属性值继承的文档中有这样一个令我犹豫的警句。
但是,只要可继承属性被注册为附加属性,并且没有遇到故意阻止继承的边界(如框架),属性值继承就可以弥补逻辑树中的这个差距,仍然可以传递继承的值。
(强调部分由我添加)
所以我的问题是:除了框架之外,还有哪些元素可以“阻止”依赖属性继承?
英文:
My WPF App attaches a custom inherited dependency property (from a behavior) to my main application view. The idea is to pass this property (which never changes once the app is running) all the way down to some very nested controls that need it
<Window x:Class="MyApp.Views.MainWindow"
core:SystemBehavior.SystemService="{Binding MySystem}"
It works well. So far, all of my controls have been able to access this data
<ComboBox ItemsSource="{Binding RelativeSource={RelativeSource Self},
Path=(core:SystemBehavior.SystemService).Units}"
But there's this ominous sentence in the MS documentation about Property Value Inheritance that gives me pause.
> However, property value inheritance can bridge this gap in the logical
> tree and can still pass inherited values through, so long as the
> inheritable property was registered as an attached property and no
> deliberate inheritance-blocking boundary (such as a Frame) is
> encountered.
(emphasis added by me)
So my question is: What elements (besides a frame) can "block" dependency property inheritance?
答案1
得分: 1
我找不到明确回答这个问题的任何文档。
我在referencesource.microsoft.com上搜索,列出了以下内容:
-
Frame(框架)
-
Page(页面)
-
DocumentReference(文档引用)
-
FixedPage(固定页面)
-
PageContent(页面内容)
英文:
I can't find any documentation that explicitly answers the question.
I searched referencesource.microsoft.com to come up with this list:
- Frame
- Page
- DocumentReference
- FixedPage
- PageContent
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论