【发布时间】:2016-02-23 17:50:42
【问题描述】:
我有DataWindow 和UserControls(不同的ViewModels)。
我的DataWindow.Xaml:
<catel:DataWindow.Resources>
<DataTemplate DataType="{x:Type viewmodels:MessageViewModel}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20*"/>
<ColumnDefinition Width="80*"/>
</Grid.ColumnDefinitions>
<Views:MessageView Grid.Column="1"/>
</Grid>
</DataTemplate>
</catel:DataWindow.Resources>
<ItemsControl ItemsSource="{Binding Messages}">
我的UserControl:MessageView.Xaml
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Border Grid.Row="0" Background="Red">
</Border>
<Border Grid.Row="1">
...
Content
...
</Border>
</Grid>
Messages : ObservableCollection<ViewModelBase>();
我在UserControl 中的内容会在运行时动态添加到DataWindow。如果UserControl 中的内容宽度大于 WindowWidth ColumnWidth(column1 20* 和 column2 80*)不起作用。我只看到 Grid.Column(80*),它的宽度是 100*。我究竟做错了什么?
感谢您的帮助!
【问题讨论】:
-
您确定您的
Views:MessageView知道父Grid- stackoverflow.com/questions/17914005/… 吗? -
感谢您的帮助!问题是“当元素的大小大于窗口大小时,不可能渲染 80% 的窗口”