catel - 即使将内容网格命名为“__catelInnerWrapper”,Catel 也会在视图模型网格中包装用户控件内容
问题描述
我在 Catel 中为 Catel 用户控件手动创建视图模型网格时遇到问题。该文档暗示,通过将内容网格命名为“__catelInnerWrapper”,ViewModelWrapperService 不会用另一个网格包装内容,而是使用我的网格。我想这样做是出于视觉状态管理的目的。使用 Snoopwpf 我可以看到用户控件仍在被包装。
(https://i.imgur.com/teSu9La.png)
我尝试使用 Catel 5.8.0 和 5.9.0 beta 0 创建一个新的 Catel 项目模板,使用 .NET 4.6.1 和主窗口中的单个用户控件来测试简化的应用程序并看到相同的行为。
<catel:UserControl x:Class="CatelTest.Views.MyUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:catel="http://schemas.catelproject.com">
<Grid x:Name="__catelInnerWrapper">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="{Binding Title}" />
<Label Grid.Row="1" Content="My User Control" />
</Grid>
</catel:UserControl>
在逐步执行 ViewModelWrappingService.xaml.cs 代码时,似乎用户控件内容名称属性始终解析为 null,因此与 InnerWrapperName 不匹配。你知道为什么会发生这种情况吗?谢谢
解决方案
查看源代码时,您正在做正确的事情。如果您 100% 确定:
- 您正在使用正确的构建(例如完全重建的应用程序,而不是错误的配置)
- 窥探是正确的
然后请在https://github.com/catel/catel/报告一个问题(最少重现),我们将确保它会在 Catel 5.9 中得到修复(目前处于测试阶段,即将发布,但我们将等待这个一)。
推荐阅读
- reactjs - 类型错误:customers.map 不是函数
- laravel - 如何设置列表的默认排序列?
- python-3.x - 参数:(ProgrammingError("(psycopg2.ProgrammingError) 不能适应类型'Tag'"),)
- dynamics-crm - 如何使用 Simple.OData.Client 在 Microsoft Dynamics 365 中获取选项列表/选项集值
- html - html自动播放音频由于某种原因无法正常工作
- python - 从控制台导入 Python 虚拟环境 (pyenv) 中的模块时出现段错误
- c# - C# linq to entity fetch 嵌套自引用查询
- node.js - MongoDB:查询大于特定值的 x 值
- c# - 如何设置不同代码行之间的延迟
- python - 单击“下一步”按钮时,我的问题不会改变,但我的 Tkinter 测验应用程序中的选项会发生变化