投稿

1月, 2017の投稿を表示しています

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の項目の並び方とかをカスタムできるようになる。