C# 未使用工具栏项资源解析视图
当Caliburn Micro framework被绑定为ShellView工具栏中的按钮列表时,它似乎没有检索到我的SinglePaintToolbarView。我希望按钮在添加到工具栏时只显示其文本内容。但是,我得到的是: 工具栏中似乎没有任何可单击的按钮。我知道我的插件正在成功加载,因为我能够将列表中的一个插件绑定为ContentControl,并且视图出现了。当我试图在工具栏中绑定插件列表时,它似乎不起作用 以下是我所拥有的: ShellView.xamlC# 未使用工具栏项资源解析视图,c#,.net,caliburn.micro,caliburn,C#,.net,Caliburn.micro,Caliburn,当Caliburn Micro framework被绑定为ShellView工具栏中的按钮列表时,它似乎没有检索到我的SinglePaintToolbarView。我希望按钮在添加到工具栏时只显示其文本内容。但是,我得到的是: 工具栏中似乎没有任何可单击的按钮。我知道我的插件正在成功加载,因为我能够将列表中的一个插件绑定为ContentControl,并且视图出现了。当我试图在工具栏中绑定插件列表时,它似乎不起作用 以下是我所拥有的: ShellView.xaml <UserControl
<UserControl x:Class="Starbolt.Views.ShellView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<ToolBarTray>
<ToolBar ItemsSource="{Binding Path=ToolbarPlugins}"/>
</ToolBarTray>
</Grid>
</UserControl>
基本上,你的设计似乎是可行的。如果你更换
<ToolBarTray>
<ToolBar x:Name="ToolbarPlugins"/>
</ToolBarTray>
SinglePaintToolView按钮按预期显示
我怀疑问题出在工具栏上,它对工具栏项布局的限制肯定比列表框更大
所以我的猜测是,如果你真的想使用工具栏控件来显示你的IToolbarPlugin视图,你可能需要在你的项目中设计一个专用的工具栏控件模板
或者,您可以使用例如ListBox实现工具栏替换。这可能是一个开始:
<ListBox x:Name="ToolbarPlugins">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
基本上,你的设计似乎是可行的。如果你更换
<ToolBarTray>
<ToolBar x:Name="ToolbarPlugins"/>
</ToolBarTray>
SinglePaintToolView按钮按预期显示
我怀疑问题出在工具栏上,它对工具栏项布局的限制肯定比列表框更大
所以我的猜测是,如果你真的想使用工具栏控件来显示你的IToolbarPlugin视图,你可能需要在你的项目中设计一个专用的工具栏控件模板
或者,您可以使用例如ListBox实现工具栏替换。这可能是一个开始:
<ListBox x:Name="ToolbarPlugins">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
是的,看起来这就是我必须要做的,才能使用工具栏。然而,ListBox解决方案对我来说非常有效。当我有时间的时候,我会对ControlTemplate做更多的研究。是的,看起来这就是我使用工具栏所必须做的。然而,ListBox解决方案对我来说非常有效。当我有时间的时候,我会对ControlTemplate进行更多的研究。
<ListBox x:Name="ToolbarPlugins"/>
<ListBox x:Name="ToolbarPlugins">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>