2017-09-27 10 views
0

に伸ばし、右別の要素を計画これは私のXAMLUWP RelativePanelは、パネル

<RelativePanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="10,0,0,0"> 
    <TextBlock x:Name="PageTitle" 
       RelativePanel.AlignTopWithPanel="True" 
       Style="{StaticResource WindowTitle}">This is my page title</TextBlock> 
    <TextBlock x:Name="ActivityLabel" 
       RelativePanel.Below="PageTitle" 
       Style="{StaticResource CaptionTitle}">Activity</TextBlock> 
    <ComboBox x:Name="ActivityOptions" 
       RelativePanel.RightOf="ActivityLabel" 
       RelativePanel.AlignRightWithPanel="True" 
       RelativePanel.AlignHorizontalCenterWith="ActivityLabel" 
       ItemsSource="{Binding Path=SupportedActivityTypes}"> 
    </ComboBox> 
</RelativePanel> 

であり、これは私が達成したいどのような私の出力 enter image description here

あるタイトルが上にあるということですタイトルの下に複数の行があります。各行にはキャプションがあり、キャプションはコンボボックス、テキストボックスなどがありますが、右側はパネルの右端に伸びる必要があります。

明らかに私のコードは機能しません。マークアップで指定されているように、コンボはキャプションテキストと中央揃えさえしません。そして、コンボの左側をキャプションテキストに、右側をパネルの境界に合わせるにはどうすればよいですか?

答えて

1

私は、私は以下のXAML

<RelativePanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="10,0,0,0"> 
    <TextBlock x:Name="PageTitle" 
       Margin="0,0,0,20" 
       RelativePanel.AlignTopWithPanel="True" 
       Style="{StaticResource WindowTitle}">This is page title</TextBlock> 
    <TextBlock x:Name="ActivityLabel" 
       RelativePanel.Below="PageTitle" 
       Style="{StaticResource CaptionTitle}">Activity</TextBlock> 
    <ComboBox x:Name="ActivityOptions" 
       Margin="10,0,0,0" 
       HorizontalAlignment="Stretch" 
       RelativePanel.RightOf="ActivityLabel" 
       RelativePanel.AlignRightWithPanel="True" 
       RelativePanel.AlignVerticalCenterWith="ActivityLabel" 
       ItemsSource="{Binding Path=SupportedActivityTypes}"> 
    </ComboBox> 
</RelativePanel> 

を必要とコンボボックスはキャプションラベル(「活性」)の同じライン上にあり、一方幅が広がって、それを考え出しました相対パネルサイズ。

0

コンボの左側をキャプションテキストに、右側をパネルの境界に合わせるにはどうすればよいですか?

RelativePanel.RightOf="PageTitle"RelativePanel.AlignVerticalCenterWith="PageTitle"を設定する必要があります。

<RelativePanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="10,0,0,0"> 
     <TextBlock x:Name="PageTitle" 
      RelativePanel.AlignTopWithPanel="True" 
      Style="{StaticResource TitleTextBlockStyle}" VerticalAlignment="Center" FontSize="35">This is my page title</TextBlock> 
     <TextBlock x:Name="ActivityLabel" 
      RelativePanel.Below="PageTitle" 
      Style="{StaticResource CaptionTextBlockStyle}">Activity</TextBlock> 
     <ComboBox x:Name="ActivityOptions" 
      RelativePanel.RightOf="PageTitle" 
      RelativePanel.AlignRightWithPanel="True" 
      RelativePanel.AlignVerticalCenterWith="PageTitle" 
      ItemsSource="{Binding Path=SupportedActivityTypes}"> 
     </ComboBox> 
</RelativePanel> 

enter image description here

+0

こんにちは、あなたは私の質問を誤解しました。私はコンボを同じ行のキャプションテキスト(アクティビティ)にしたい。しかし、後で調整を加えることで解決策を試すことができます。 – hardywang

+0

@ハディワン。コンボを同じ行のキャプションテキスト(アクティビティ)にしたい場合は、あなたが言ったように、 'RelativePanel.RightOf =" ActivityLabel "と' RelativePanel.AlignVerticalCenterWith = "ActivityLabel"を設定する必要があります。 –

関連する問題