UWP Xaml相对面板、拉伸和其他元素
我创建UWP应用程序并使用RelativePanel。 我使用相对面板.alignwithright、top、left和bottom面板将宽度拉伸到listview。 但在将其他元素(例如Stackpanel)添加到listview右侧后,其他面板不会在页面中查看。 所以我删除了relativePanel.AlignWithRight,在这种情况下不能在listview中进行宽度拉伸 我能做什么 代码:UWP Xaml相对面板、拉伸和其他元素,xaml,uwp,uwp-xaml,Xaml,Uwp,Uwp Xaml,我创建UWP应用程序并使用RelativePanel。 我使用相对面板.alignwithright、top、left和bottom面板将宽度拉伸到listview。 但在将其他元素(例如Stackpanel)添加到listview右侧后,其他面板不会在页面中查看。 所以我删除了relativePanel.AlignWithRight,在这种情况下不能在listview中进行宽度拉伸 我能做什么 代码: 测试数据 我敢肯定,在纯XAML中,仅通过设置一些RelativePanel附加的属性
测试数据
我敢肯定,在纯XAML中,仅通过设置一些RelativePanel附加的属性是无法做到这一点的,但您可以处理RelativePanel的SizeChanged事件,并通过编程方式设置ListView的宽度。这是一条单行线:
private void Information_SizeChanged(object sender, SizeChangedEventArgs e)
{
MyList.Width = Information.ActualWidth - TotalInformation.ActualWidth;
}
测试数据
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>