【发布时间】:2013-09-03 03:02:11
【问题描述】:
如何设置自定义控件的设计时宽度和高度?
我创建了一个自定义 ItemsControl,即(generic.xaml 的内容)
<Style TargetType="{x:Type MyItemsControl}" >
<Setter Property="Height" Value="24" />
<Setter Property="Width" Value="160" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:MyItemsControl}" >
<Grid>
...
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
...
</Style>
而且它工作得很好,但是如果我将控件从工具箱拖到我的窗口上,我的控件的默认大小是:高度 = 100 和宽度 = 200。我如何设置设计时大小,以便当我将控件从工具箱拖到窗口默认大小分别是24和160?
【问题讨论】:
标签: c# wpf visual-studio-2010