我正在尝试在另一个视图中使用 coproject 工具栏。无法让它工作
我正在尝试在另一个视图(ActiveItem)中使用 coproject 工具栏类型的视图。 Coproject 定义了两个内容控件。但我希望工具栏嵌套在另一个视图中。基本上是 CRUD 表单(视图)的一部分,因此我可以像许多其他表单/视图中的用户控件一样使用它。我尝试将 Contentcontrol 包含在我的视图中。但工具栏永远不会显示。它抱怨未找到 Project.Views.Form.tbar。如何强制它使用工具栏视图但使用当前视图模型 FormViewModel。任何有关自定义视图定位器的帮助都会非常有帮助。
假设有两个视图:FormView 和 FormView。工具栏(工具栏应该使用 FormViewModel)
FormView.xaml:(我在此使用工具栏视图)
<UserControl x:Class="Project.Views.FormView"
<Grid>
<Othercontrols>
<ContentControl x:Name="Toolbar" cal:View.Model="{Binding}" cal:View.Context="tbar" />
<OtherControls>
</Grid>
</UserControl>
Toolbar.xaml:
<UserControl x:Class="Project.Views.Toolbar">
<Border>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Height="28" Width="135">
<local:ImageButton x:Name="Add" ImageName="Pen" ToolTipService.ToolTip="Add" />
<local:ImageButton x:Name="Edit" ImageName="Pen" ToolTipService.ToolTip="Edit" />
<local:ImageButton x:Name="Save" ImageName="Save" ToolTipService.ToolTip="Save" />
<local:ImageButton x:Name="Delete" ImageName="Close" ToolTipService.ToolTip="Delete" />
<local:ImageButton x:Name="Cancel" ImageName="Undo" ToolTipService.ToolTip="Cancel" />
</StackPanel>
</Border>
</UserControl>
正如我之前所说,工具栏应该使用它所使用的父视图模型。在上述情况下,应该使用 FormViewModel。 FormViewModel 将具有“添加”、“编辑”等方法。
请让我知道如何使其工作? 非常感谢。
I'm trying to use the coproject toolbar kind of view inside another view (ActiveItem). Coproject defines two content controls. But I want the toolbar to be nested in another view. Basically part of a CRUD form (view) so I can use it like a usercontrol in many other forms/views. I tried to include the Contentcontrol in my view. But the toolbar nevers shows up. It complains Project.Views.Form.tbar not found. How do I force it use the Toolbar view but use current viewmodel FormViewModel. Any help on customizing View locator would be very helpful.
Say there are two views: FormView & Toolbar (Toolbar should use the FormViewModel)
FormView.xaml: (I'm using toolbar view in this)
<UserControl x:Class="Project.Views.FormView"
<Grid>
<Othercontrols>
<ContentControl x:Name="Toolbar" cal:View.Model="{Binding}" cal:View.Context="tbar" />
<OtherControls>
</Grid>
</UserControl>
Toolbar.xaml:
<UserControl x:Class="Project.Views.Toolbar">
<Border>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Height="28" Width="135">
<local:ImageButton x:Name="Add" ImageName="Pen" ToolTipService.ToolTip="Add" />
<local:ImageButton x:Name="Edit" ImageName="Pen" ToolTipService.ToolTip="Edit" />
<local:ImageButton x:Name="Save" ImageName="Save" ToolTipService.ToolTip="Save" />
<local:ImageButton x:Name="Delete" ImageName="Close" ToolTipService.ToolTip="Delete" />
<local:ImageButton x:Name="Cancel" ImageName="Undo" ToolTipService.ToolTip="Cancel" />
</StackPanel>
</Border>
</UserControl>
As I said earlier, the Toolbar should use the parent view model where it is used. In above case, it should use FormViewModel. The FormViewModel will have the methods "Add", "Edit" and etc.
Please let me know how to get this working?
Thanks much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 cal:View.Model="{Binding Parent}" 怎么样?前提是子 ViewModel 具有用正确的父 ViewModel 填充的此属性。
What about to use cal:View.Model="{Binding Parent}"? Provided that the child ViewModel has this property filled with proper parent ViewModel.