ListBoxにヘッダとフッタを設定してひっぱらないと見えない様にする

後ほど詳細な記事を書きます。

ListBoxのスタイルの再定義を行います。

    <phone:PhoneApplicationPage.Resources>
		<Style x:Key="ListBoxStyle1" TargetType="ListBox">
			<Setter Property="Background" Value="Transparent"/>
			<Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
			<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
			<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
			<Setter Property="BorderThickness" Value="0"/>
			<Setter Property="BorderBrush" Value="Transparent"/>
			<Setter Property="Padding" Value="0"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="ListBox">
						<ScrollViewer x:Name="ScrollViewer" DataContext="{Binding}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" Padding="{TemplateBinding Padding}">
							<StackPanel>
								<!-- ここにヘッダ -->
								<ItemsPresenter/>
								<!-- ここにフッタ -->
							</StackPanel>
						</ScrollViewer>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
    </phone:PhoneApplicationPage.Resources>

あとはListBoxへListBoxStyle1のStyle設定を行います。

応用例としてListBoxをぐぐっと引っ張った時だけ見えるヘッダとフッタの作り方を紹介します。