【发布时间】:2021-05-31 18:01:11
【问题描述】:
我有一个带有 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"
对导致错误的原因有什么建议吗?
【问题讨论】:
-
尝试将项目的目标框架切换到更高版本。 .Net Framework 版本之间可能存在差异。
-
这只是设计者的问题,即当您运行应用程序时它是否有效?
-
这不是设计师独有的问题。创建具有该样式的视图时,应用程序会严重崩溃。
-
@Rekshino 这是我不同项目中 DevExpress 版本之间的不匹配,您的评论为我指明了正确的方向。谢谢!
标签: c# wpf xaml devexpress-wpf