私は自分のメニューコントロールのスタイルを作ったので、今度はそのスタイルをすべてのmenuItemに使用したいが、テキストボックスには異なるテキストが使われている。私はリストを使用してバインディング要素を設定することができるかどうか疑問に思っていました...私は試みましたが動作しませんでした...何かを見逃したり、別のものを使用しなければなりませんか?リストを使用してメニューコントロールでバインドすることはできますか?
List<string> itemArray = new List<string>();
itemArray.Add("label1");
itemArray.Add("label2");
itemArray.Add("label3");
Binding binding = new Binding();
binding.Path = new PropertyPath("itemArray");
this.menu1.SetBinding(TextBox.TextProperty, binding);
、それが助け場合は、スタイルの一部は、ある...:
<Setter.Value>
<ControlTemplate TargetType="{x:Type MenuItem}">
<Grid>
<Border Name="MainBorder" BorderThickness="2,2,2,0" >
<Grid>
<TextBlock Text="{Binding Path=itemArray}" Margin="30,10,0,0" FontFamily="Arial" FontSize="14" FontWeight="Bold" />
<Image Width="15" Height="15" Source="image.PNG" Margin="-100,0,0,0" />
</Grid>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
HeaderedItemsControl機能の概要については、[MenuItem](http://msdn.microsoft.com/en-us/library/system.windows.controls.menuitem.aspx)のMSDNドキュメントの「備考」セクションを参照してください。およびMenuItemsでのデータバインディングの使用方法について説明します。 – Clemens