我试图动态添加按钮并且它起作用,但命令不起作用。
我收到错误
ItemTemplate和ItemTemplateSelector将被ItemsControl的容器类型的项目忽略;类型=' RadRibbonButton'
<telerik:RadRibbonGroup>
...
<telerik:RadRibbonGroup.DataContext>
<vm:Group1/>
</telerik:RadRibbonGroup.DataContext>
<ItemsControl ItemsSource="{Binding ButtonsCollection}" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Content="{Binding}" Command="{Binding DataContext.ButtonCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadRibbonGroup}}}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</telerik:RadRibbonGroup>
ButtonCommand= new DelegateCommand(ExecuteCommand);
private void ExecuteCommand()
{
...
}
答案 0 :(得分:0)
答案 1 :(得分:0)
3.我应该创建并添加按钮到集合运行时(这背后有特殊的逻辑)。在构造函数中我创建命令