こんにちは。WPFのテンプレートについて教えてください。
xamlで
<Button Content="test">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Label Content="{TemplateBinding Content}" />
</ControlTemplate>
</Button.Template>
</Button>
と書いてあるものを、C#のコードで書くとしたら、どうなりますか?
Button button = new Button();
button.Content = "test";
ControlTemplate template = new ControlTemplate();
template.TargetType = typeof(Button);
Binding binding = new Binding();
binding.Source = template;
Label label = new Label();
label.Content = binding;
でなんとなくかたちはできたように思えたのですが、BindingとTemplateのあたりの親子関係がわからず、XAMLとは違った結果(外観がボタン)になっています。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/04/15 19:50