2016-12-10 7 views
0

私はUWPアプリケーションを作成し、RelativePanelを使用します。 リストビューの幅を広げるために相対panel.alignwithright、top、left、bottomパネルを使用します。 しかし、他の要素(例:Stackpanel)をリストビューの右側に追加した後、他のパネルはページに表示されません。 したがって、relativePanel.AlignWithRightを削除します。この場合、リストビューで幅を伸ばすことはできません。UWP Xaml相対パネル、伸縮その他の要素

私は何ができますか?

I want this shape to come out.

Now RelativePanel

コード:

<RelativePanel x:Name="Information" Grid.Row="1"> 
      <ListView x:Name="MyList" 
         RelativePanel.AlignBottomWithPanel="True" 
         RelativePanel.AlignTopWithPanel="True" 
         RelativePanel.AlignRightWithPanel="True" 
         RelativePanel.AlignLeftWithPanel="True"> 
       <ListView.ItemTemplate> 
        <DataTemplate> 
         <userControl:SpendListItem_Template Tapped="SpendListItem_Template_Tapped" ></userControl:SpendListItem_Template> 
        </DataTemplate> 
       </ListView.ItemTemplate> 

       <ListView.ItemContainerStyle> 
        <Style TargetType="ListViewItem"> 
         <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter> 
         <Setter Property="Margin" Value="10,0,10,10"></Setter> 
        </Style> 
       </ListView.ItemContainerStyle> 
      </ListView> 

      <StackPanel x:Name="TotalInformation" RelativePanel.RightOf="MyList" Width="100"> 
       <TextBlock>Test Data</TextBlock> 
      </StackPanel> 
     </RelativePanel> 

答えて

1

私はあなただけRelativePanel添付プロパティの一部を設定することにより、純粋なXAMLでこれを行うことはできませんが、あなたが扱うことができるかなり確信していますRelativePanelのSizeChangedイベントを使用して、プログラムでListViewの幅を設定します。

private void Information_SizeChanged(object sender, SizeChangedEventArgs e) 
{ 
    MyList.Width = Information.ActualWidth - TotalInformation.ActualWidth; 
} 

<RelativePanel x:Name="Information" Grid.Row="1" SizeChanged="Information_SizeChanged"> 
     <ListView x:Name="MyList"> 
      <ListView.ItemTemplate> 
       <DataTemplate> 
        <userControl:SpendListItem_Template Tapped="SpendListItem_Template_Tapped" ></userControl:SpendListItem_Template> 
       </DataTemplate> 
      </ListView.ItemTemplate> 

      <ListView.ItemContainerStyle> 
       <Style TargetType="ListViewItem"> 
        <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter> 
        <Setter Property="Margin" Value="10,0,10,10"></Setter> 
       </Style> 
      </ListView.ItemContainerStyle> 
     </ListView> 

     <StackPanel x:Name="TotalInformation" RelativePanel.RightOf="MyList" Width="100"> 
      <TextBlock>Test Data</TextBlock> 
     </StackPanel> 
</RelativePanel> 
+0

感謝:これは、1つのライナーです。それはとてもうまくいく。 –

関連する問題