2012-07-25 6 views

답변

0

페이지의 기본 그리드가 2 행인지 확인하십시오. 만들기는 3 .. 자동 높이 .. 중간 세트 *로 설정 상단과 하단 행

5

물론, 여기에 코드와 레이아웃

<Grid x:Name="LayoutRoot" Background="Transparent"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="100"/> 
     <RowDefinition Height="*"/> 
     <RowDefinition Height="100"/> 
    </Grid.RowDefinitions> 

    <TextBlock Text="I AM HEADER" Grid.Row="0" FontSize="56"/> 
    <StackPanel Grid.Row="1" > 
     <TextBlock Text="Main content goes here. Main content goes here. " TextWrapping="Wrap" FontSize="56"/> 
    </StackPanel> 
    <TextBlock Text="I AM FOOTER" Grid.Row="2" FontSize="56"/> 

</Grid> 

enter image description here

1

당신이 원하는 경우에 뭔가 있음을 반복해서 사용할 수 있습니다. 사용자 지정 컨트롤을 만드는 것이 좋습니다. 이 컨트롤은 귀하의 페이지에서 쉽게 사용할 수 있습니다.

사용자 지정 컨트롤 :

public class HeaderFooterControl : ContentControl 
{ 
    public object Header 
    { 
     get { return (object)GetValue(HeaderProperty); } 
     set { SetValue(HeaderProperty, value); } 
    } 

    // Using a DependencyProperty as the backing store for Header. This enables animation, styling, binding, etc... 
    public static readonly DependencyProperty HeaderProperty = 
     DependencyProperty.Register("Header", typeof(object), typeof(HeaderFooterControl), new PropertyMetadata(null)); 

    public object Footer 
    { 
     get { return (object)GetValue(FooterProperty); } 
     set { SetValue(FooterProperty, value); } 
    } 

    // Using a DependencyProperty as the backing store for Header. This enables animation, styling, binding, etc... 
    public static readonly DependencyProperty FooterProperty = 
     DependencyProperty.Register("Footer", typeof(object), typeof(HeaderFooterControl), new PropertyMetadata(null)); 

    // TODO: Templates for Header and Footer 
} 

XAML 정의에 대한 제어 :

<phone:PhoneApplicationPage 
    xmlns:controls="clr-namespace:MyLocalNamespace" 
    <!-- Other parts of the page to declare (eg: FontSize, Foreground, etc) 
    <controls:HeaderFooterControl Header="Hello Header!" Footer="Bottom of page!"> 
     <!-- Other content for your page here! --> 
    </controls:HeaderFootControl> 

당신이에 추가 할 수 있습니다 같은 같은 당신이 페이지는 경우

<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:controls="clr-namespace:MyLocalNamespace"> 
    <Style TargetType="controls:HeaderFooterControl"> 
     <Setter Property="Header" Value="Header info"/> 
     <Setter Property="Footer" Value="Footer info"/> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="controls:HeaderFooterControl"> 
        <Grid Background="{TemplateBinding Background}"> 
         <Grid.RowDefinitions> 
          <RowDefinition Height="Auto"/> 
          <RowDefinition Height="*"/> 
          <RowDefinition Height="Auto"/> 
         </Grid.RowDefinitions> 

         <ContentPresenter Content="{TemplateBinding Header}"/> 
         <ContentPresenter Content="{TemplateBinding Content}" Grid.Row="1"/> 
         <ContentPresenter Content="{TemplateBinding Footer}" Grid.Row="2"/> 

        </Grid> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 
</ResourceDictionary> 

그런 다음 컨트롤을 사용합니다 솔루션은 HeaderTemplate과 FooterTemplate을 설정할 수도 있습니다. 맞춤 컨트롤 here에 대해 자세히 알아볼 수 있습니다.

관련 문제