XAML ContentControl子项未拉伸以填充ContentControl

时间:2016-11-04 19:09:41

标签: xaml uwp

我有一件非常简单的事情,我正在尝试但它不起作用,我正在努力理解我所缺少的东西。

所以我在父UI中有<ContentControl>并将其Content属性绑定到控制器上的DependencyProperty:

<ContentControl x:Name="rightPanel">

(它位于Grid中,行高设置为*。)

然后我实例化一个包含Grid的UserControl(因此应该拉伸以填充可用空间),但每当我将其嵌入到UserControl中时,它都会失去所有“拉伸”并开始缩小,就像它在StackPanel中一样

<UserControl
    *namespace snip*>
    <Grid Background="LightGreen">
        <TextBlock Text="Oh happy days..."/>
    </Grid>
</UserControl>

...

var innerPage = new MyUserControl1(); // the above <UserControl>
this.rightPanel.Content = innerPage;

enter image description here

我无法弄清楚为什么会这样。我已经尝试了UserControlPage s,没有区别。我错过了什么?

1 个答案:

答案 0 :(得分:3)

将ContentControl的Horizo​​ntalContentAlignment / VerticalContentAlignment设置为Stretch。

相关问题