wpf共享ResourceDictionary文件参数?
如果所有样式和转换器都存储在共享资源字典文件(styles.xaml)中,并且该文件在各个窗口中使用。
是否可以将参数传递给该文件,并将该参数传播给转换器?
我正在寻找一种传递“origin”类型参数的方法,以便转换器可以知道它们是从哪个位置使用的?只是提示当前哪个窗口/网格正在使用转换器。
if all Styles and Converters are stored in shared resource dictionary file (styles.xaml), and this file is used from various windows.
Is it possible, to pass a parameter to that file, and propagate that parameter to the converters?
I am looking for a way to pass a "origin" type parameter, so that the converters could be aware which place they are being used from? Just a hint of which window/grid is using the converter at the moment..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想知道这样的方法是否可行:
在每个 Window 或 UserControl 的声明中添加对 System 命名空间的引用。
然后在您的资源部分中进行如下设置:
您的绑定语法可能如下所示:
...并且您的转换类中的 Convert 或 ConvertBack 方法然后会意识到正在使用它们的 Window,只要您改变 的值
从一个文件到另一个文件。你怎么认为?
I wonder if something like this will work:
Add a reference to the System namespace in the declaration of each Window or UserControl where you want this.
Then in your resources section set things up like this:
Your binding syntax could then look something like this:
...and your Convert or ConvertBack methods in your conversion classes then become aware of the Window that's using them, provided you vary the value of that
<sys:String/>
from file to file.What do you think?