1
我有以下代碼:WPF動態添加RibbonApplicationMenuItem(S)
<ribbon:Ribbon.ApplicationMenu>
<ribbon:RibbonApplicationMenu ToolTipTitle="Application Menu">
<ribbon:RibbonApplicationMenuItem Header="Company"
x:Name="MenuItem_Company"
ImageSource="Images\LargeIcon.png"
Command="{Binding Path=CompanyCommand}">
<StackPanel>
<TextBlock Text="Item 1 in the list" />
<TextBlock Text="Item 2 in the list" />
<TextBlock Text="Item 3 in the list" />
<TextBlock Text="Item 4 in the list" />
</StackPanel>
</ribbon:RibbonApplicationMenuItem>
<ribbon:RibbonApplicationMenuItem Header="DocStore Settings"
x:Name="MenuItem1"
ImageSource="Images\LargeIcon.png"
Click="MenuItem1_Click"/>
<ribbon:RibbonApplicationMenuItem Header="About DocStore"
x:Name="MenuItem2"
ImageSource="Images\LargeIcon.png"
Click="MenuItem2_Click" />
<ribbon:RibbonApplicationMenuItem Header="Exit"
x:Name="MenuExit"
ImageSource="Images\LargeIcon.png"
Click="Exit" />
</ribbon:RibbonApplicationMenu>
</ribbon:Ribbon.ApplicationMenu>
我想動態地添加項目到我的堆疊面板第一RibbonApplicationMenuItem替換是硬編碼將TextBlock裏面的物品。我不知道有多少可用,我以4爲例。
這可能嗎?如果是這樣,我該如何去做呢?
謝謝! Eroc