UWPでIsItemsHost="True"を使う
WPFで書かれている完全カスタムカレンダーを作るやつをUWPにしたかった。
が
<ListBox.Template> <ControlTemplate TargetType="{x:Type ListBox}"> <StackPanel> <UniformGrid Columns="7" IsItemsHost="True"> </UniformGrid> </StackPanel> </ControlTemplate> </ListBox.Template> これの IsItemsHostプロパティがsetできない。
解決方法はこれ(アイテムコントロールのテンプレート)。
ItemsPresenterを使うItemsPanel プロパティ(ItemsPanelTemplate 型)を設定する<ListBox.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal"/> </ItemsPanelTemplate> </ListBox.ItemsPanel>
これでListBoxの項目の並び方とかをカスタムできるようになる。
が
<ListBox.Template> <ControlTemplate TargetType="{x:Type ListBox}"> <StackPanel> <UniformGrid Columns="7" IsItemsHost="True"> </UniformGrid> </StackPanel> </ControlTemplate> </ListBox.Template> これの IsItemsHostプロパティがsetできない。
解決方法はこれ(アイテムコントロールのテンプレート)。
ItemsPresenterを使うItemsPanel プロパティ(ItemsPanelTemplate 型)を設定する<ListBox.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal"/> </ItemsPanelTemplate> </ListBox.ItemsPanel>
これでListBoxの項目の並び方とかをカスタムできるようになる。