问题描述
限时送ChatGPT账号..我正在使用 Caliburn Micro 开发 Windows 应用商店应用程序.
I'm developing Windows Store App with using Caliburn Micro.
在其中一个页面中,我有 ContentControl
,显示 UserControl
.在 UserControl
我有 GridView
.
我的问题是:如何设置 UserControl.Width
与 ContentControl 相同.宽度
?
注意:设置UserControl.Width=Auto
- 宽度与GridView.Width
In one of the pages I have ContentControl
, which display UserControl
. In UserControl
I have GridView
.
My question is: How to set UserControl.Width
same as ContentControl.Width
?
Note: whet set UserControl.Width=Auto
- width the same as GridView.Width
在 page.xaml 中
in page.xaml
<ContentControl x:Name="ActiveItem" />
在 usercontrol.xaml 中
in usercontrol.xaml
<UserControl
x:Class="Test.Views.GroupView"
xmlns="http://schemas.microsoft/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats/markup-compatibility/2006"
mc:Ignorable="d" Width="Auto" Height="Auto">
<Grid Margin="0,20">
<GridView x:Name="Groups" Margin="0" />
</Grid>
</UserControl>
更新
添加
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
To UserControl
不能解决问题.
To UserControl
doesn't solve the problem.
推荐答案
特别是@AlexeiMalashkevich
我使用这样的绑定来解决它:
Especially for @AlexeiMalashkevich
I solve it with using binding like this:
在根页面中,您有:
In root Page you have:
<ContentControl x:Name="ActiveItem"/>
然后添加子页面:
<Page
Height="{Binding ActualHeight, ElementName=ActiveItem}"
Width="{Binding ActualWidth, ElementName=ActiveItem}"
......
/>
仅此而已.
这篇关于具有嵌套宽度/高度的 ContentControl 内的 UserControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论