<bdo id='zNINh'></bdo><ul id='zNINh'></ul>
        <i id='zNINh'><tr id='zNINh'><dt id='zNINh'><q id='zNINh'><span id='zNINh'><b id='zNINh'><form id='zNINh'><ins id='zNINh'></ins><ul id='zNINh'></ul><sub id='zNINh'></sub></form><legend id='zNINh'></legend><bdo id='zNINh'><pre id='zNINh'><center id='zNINh'></center></pre></bdo></b><th id='zNINh'></th></span></q></dt></tr></i><div id='zNINh'><tfoot id='zNINh'></tfoot><dl id='zNINh'><fieldset id='zNINh'></fieldset></dl></div>
      1. <tfoot id='zNINh'></tfoot>

        <legend id='zNINh'><style id='zNINh'><dir id='zNINh'><q id='zNINh'></q></dir></style></legend>

        <small id='zNINh'></small><noframes id='zNINh'>

      2. 我可以让 WPF ListBox 从父元素继承画笔吗?

        时间:2023-10-06

      3. <legend id='Z7PBr'><style id='Z7PBr'><dir id='Z7PBr'><q id='Z7PBr'></q></dir></style></legend>
            <bdo id='Z7PBr'></bdo><ul id='Z7PBr'></ul>
          • <tfoot id='Z7PBr'></tfoot>
            <i id='Z7PBr'><tr id='Z7PBr'><dt id='Z7PBr'><q id='Z7PBr'><span id='Z7PBr'><b id='Z7PBr'><form id='Z7PBr'><ins id='Z7PBr'></ins><ul id='Z7PBr'></ul><sub id='Z7PBr'></sub></form><legend id='Z7PBr'></legend><bdo id='Z7PBr'><pre id='Z7PBr'><center id='Z7PBr'></center></pre></bdo></b><th id='Z7PBr'></th></span></q></dt></tr></i><div id='Z7PBr'><tfoot id='Z7PBr'></tfoot><dl id='Z7PBr'><fieldset id='Z7PBr'></fieldset></dl></div>

                    <tbody id='Z7PBr'></tbody>

                  <small id='Z7PBr'></small><noframes id='Z7PBr'>

                1. 本文介绍了我可以让 WPF ListBox 从父元素继承画笔吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的 WPF 窗口将其前景画笔设置为资源字典中的画笔,并且我希望窗口中的所有文本都具有这种颜色,因此我不会在其他任何地方触摸前景画笔.

                  My WPF window has its foreground brush set to a brush from a resource dictionary, and I want all text in the window to have this color, so I don't touch the foreground brush in anything else.

                  文本框获得颜色
                  文本块获得颜色
                  按钮获得颜色

                  Textboxes get the color
                  Textblocks get the color
                  Buttons get the color

                  列表框不获取颜色,因此它们的内容也不获取.

                  Listboxes do not get the color, and so neither do their contents.

                  有没有办法让列表框在这方面表现得像其他控件?

                  Is there any way to get a Listbox to behave like the other controls in this respect?

                  假设不是,而且这是设计使然,原因是什么?

                  Assuming not, and that this is by design, what is the rationale?

                  看来我的问题还不够清楚.

                  It seems my question is not clear enough.

                  我了解如何创建样式和资源并将它们应用到 ListBoxes;我想知道为什么我需要为某些控件执行此操作,而我 不需要 需要为其他控件执行此操作 - 为什么有些继承属性而其他不包含 - 以及是否有任何方法可以使它们全部以同样的方式继承.

                  I understand how to create styles and resources and apply them to ListBoxes; I'm wondering why I need to do this for certain controls when I do not need to for others -- why some inherit properties and others do not -- and whether there is any way to make them all inherit in the same way.

                  推荐答案

                  ListBox 和其他一些控件没有继承 Foreground 属性的原因是它被默认样式的 Setter 显式覆盖.不幸的是,即使您为不包含 Foreground 属性设置器的 ListBox 分配了自定义样式,它仍然会在尝试继承其父级的值之前回退到使用默认样式.

                  The reason the ListBox and some other controls are not inheriting the Foreground property is that it is explicitly overridden with a Setter in the default style. Unfortunately even if you assign a custom style to the ListBox that doesn't include the Foreground property setter, it will still fall back to using the default style before attempting to inherit the value of its parent.

                  确定属性值的优先顺序为:

                  The order of precedence for determining the property value is:

                  1. 本地价值
                  2. 样式触发器
                  3. 模板触发器
                  4. 样式设置器
                  5. 主题风格触发器
                  6. 主题风格设置器
                  7. 属性值继承
                  8. 默认值

                  由于 #6 是在控件的默认样式中定义的,因此 WPF 不会尝试确定 #7 的值.

                  Since #6 is defined in the default style for the control, WPF does not attempt to determine the value of #7.

                  这篇关于我可以让 WPF ListBox 从父元素继承画笔吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:WPF 的拖放列表框 下一篇:如何在列表框中显示文件名但使用 openfiledialog 保留相对路径?

                  相关文章

                  <i id='T47QK'><tr id='T47QK'><dt id='T47QK'><q id='T47QK'><span id='T47QK'><b id='T47QK'><form id='T47QK'><ins id='T47QK'></ins><ul id='T47QK'></ul><sub id='T47QK'></sub></form><legend id='T47QK'></legend><bdo id='T47QK'><pre id='T47QK'><center id='T47QK'></center></pre></bdo></b><th id='T47QK'></th></span></q></dt></tr></i><div id='T47QK'><tfoot id='T47QK'></tfoot><dl id='T47QK'><fieldset id='T47QK'></fieldset></dl></div>

                  <legend id='T47QK'><style id='T47QK'><dir id='T47QK'><q id='T47QK'></q></dir></style></legend>
                  1. <small id='T47QK'></small><noframes id='T47QK'>

                      • <bdo id='T47QK'></bdo><ul id='T47QK'></ul>

                      <tfoot id='T47QK'></tfoot>