如何以编程方式访问 System.Windows.ResourceDictionary?
我正在尝试实现 InkCanvas 的加载/保存注释(复杂的子项,不是墨迹笔划,如可编辑文本框),当我使用 XamlReader.Load 时,出现异常,它试图将某些内容加载到已经存在的字典中那里。我相信我需要访问字典并检查是否已有某些内容或将其清除。
我的问题是,如何以编程方式访问资源字典或者是否有更好的方法来处理这个问题?
I am trying to implement Load/Save annotations (complex children, not ink strokes, like an editable text box) of an InkCanvas and when I use XamlReader.Load I get an exception where it is trying to load something into the dictionary that is already there. I believe I need to access the dictionary and either check to see if something is already there or just clear it out.
My question is, how can I access the resource dictionary programmatically or is there a better way to handle this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所有 FrameworkElement 派生类都包含一个 Resources 属性可用于访问该元素的资源字典。您还可以直接访问 Application.Resources,如果资源是在应用程序级别定义的。
All FrameworkElement derived classes include a Resources property you can use to access the resource dictionary for that element. You can also directly access Application.Resources if the resource is defined at the Application level.