如何解决外部文件中的 WPF 样式崩溃
我有一个带有 DevExpress GridControl 的 C# 用户控件。 当我在本地 xaml 文件中为 GridColumns 使用样式时,如下所示,一切正常
<UserControl.Resources>
<ResourceDictionary>
<Style x:Key="K2M_GridColumn" TargetType="{x:Type dxg:GridColumn}">
<Setter Property="AllowBestFit" Value="True" />
<Setter Property="AllowColumnFiltering" Value="False" />
<Setter Property="AllowEditing" Value="False" />
<Setter Property="AllowSorting" Value="False" />
</Style>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/RefImpl.Common.Client;component/Controls/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
如果我将上面的 GridColumn 样式移动到 Styles.xaml 中,VS 设计器会中断并显示这一点。
Exception: An error occurred while finding the resource dictionary "/RefImpl.Common.Client;component/Controls/Styles.xaml".
Error XDG0012 The member "AllowBestFit" is not recognized or is not accessible.
Error XDG0012 The member "AllowColumnFiltering" is not recognized or is not accessible.
...
如果我从 Styles.xaml 中删除 GridColumn 样式,一切都会编译并运行,除了我没有样式 ofc。 所以只要我不将 GridColumn 样式添加到 Styles.xaml 文件中,一切正常。
我已经在本地 xaml 文件和 Styles.xaml 文件的顶部定义了这个
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
对导致错误的原因有任何建议吗?
解决方法
我发现了问题!这是 DevExpress 的版本不匹配。 在带有 xaml 控件的项目中,我使用的是较旧版本的 DevExpress,而在带有 Styles.xaml 的项目中,我使用的是较新版本的 DevExpress。
由于某些未知原因导致运行时严重崩溃和设计器问题。但没有错误消息。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。