最終更新:
WPF/テンプレート の変更点
- 追加された行はこの色です。
- 削除された行はこの色です。
- WPF/テンプレート へ行く。
- WPF/テンプレート の差分を削除
[[WPF]]
*用語 [#gd68cbad]
**[[コントロールテンプレート]] [#v66b0d19]
-コントロールの外観を自由自在にカスタマイズ可能
-[[Control.Template]] (型:[[System.Windows.Controls.ControlTemplate]])
#geshi(xml){{
<Button>
<Button.Template>
<ControlTemplate TargetType="Button">
<Ellipse Fill="LightBlue" Width="80" Height="30"/>
</ControlTemplate>
</Button.Template>
</Button>
}}
-[[TargetType]]: テンプレートを適用するコントロールの型
**[[データテンプレート]] [#re9550b6]
-[[Binding]]
-[[System.Windows.DataTemplate]]
--[[ItemsControl.ItemTemplate]]
*種類 [#qd796690]
**[[Control.Template]] (型:[[System.Windows.Controls.ControlTemplate]]) [#b7e607b9]
-コントロール自体のカスタマイズ
#geshi(){{
<ItemsControl.Template>
<ControlTemplate TargetType="ItemsControl">
<Border BorderThickness="1"
BorderBrush="Black"
Background="Azure">
<ItemsPresenter Margin="10" />
</Border>
</ControlTemplate>
</ItemsControl.Template>
}}
**[[ItemsControl.ItemsPanel]] (型:[[System.Windows.Controls.ItemsPanelTemplate]]) [#l8c0704b]
-コレクション項目をどのようにレイアウトするかを決定
#geshi(){{
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<!-- (1) <StackPanel Orientation="Vertical" /> -->
<!-- (2) <WrapPanel Orientation="Horizontal" /> -->
<!-- (3) <Grid /> -->
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
}}
**[[ItemsControl.ItemContainerStyle]] [#hec45dbc]
-コレクションのコンテナのカスタマイズ
-[[ListBox]]が生成するコンテナー要素は[[ListBoxItem]]
-[[ComboBox]]が生成するコンテナー要素は[[ComboBoxItem]]
**[[ItemsControl.ItemTemplate]] (型:[[System.Windows.DataTemplate]]) [#q953bc2c]
-項目ごとの外観のカスタマイズ
#geshi(){{
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Margin="5">
<Run Text="No." />
<Run Text="{Binding Number}" />
<LineBreak />
<Run Text="Name:" />
<Run Text="{Binding Name}" FontSize="15" />
</TextBlock>
</DataTemplate>
</ItemsControl.ItemTemplate>
}}
*参考 [#b82f69a3]
-https://docs.microsoft.com/ja-jp/dotnet/framework/wpf/data/data-templating-overview
-http://ufcpp.net/study/dotnet/wpf_template.html
*関連 [#p75058de]
-[[System.Windows.Controls.ItemsControl]]
-[[WPF/リソース]]
-[[WPF/スタイル]]