このようなボタンを複数作りたい
<Button>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"></ColumnDefinition>
<ColumnDefinition Width="3*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" name="lblShortcut">F1</Label>
<Label Grid.Column="1" name="lblText">search</Label>
</Grid>
</Button>
したがって、テンプレートのようなものを使用する必要があることはわかっており、これらのボタンを次のようなクラスにバインドしたいと考えています。
class SearchButtonContent
{
public string Shortcut { get ; set; }
public string Text { get ; set; }
}
a がおよびにShortcut
バインドされるような方法で。実行時にコードでこれらのボタンを作成する可能性があるエレガントなテンプレートでこれを達成する最良の方法は何ですか?lblShortcut
Text
lblText