我试图创建一个类型GridLength的StaticResource以在我的XAML中使用。我想定义统一宽度的列,但我似乎无法在Xaml中找到允许我定义StaticResource的Namespace。在文档中,我发现GridLength结构存在于这个命名空间Windows.UI.Xaml;然而,当我尝试在我的Xaml文件的顶部包含名称空间时,我似乎无法找到它。用于创建GridLength的StaticResource的命名空间
这是我的XAML:
<UserControl ...
xmlns:windows="clr-namespace:System.Windows.UI.Xaml;" >
<UserControl.Resources>
<windows:GridLength property="doubleLength" x:Key="MyColumnWidth">50</windows:GridLength>
</UserControl.Resources>
...
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{StaticResource MyColumnWidth}"/>
<ColumnDefinition Width="{StaticResource MyColumnWidth}"/>
<ColumnDefinition Width="{StaticResource MyColumnWidth}"/>
</Grid.ColumnDefinitions>
....
</Grid>
</UserControl>
这里是我的问题:1。 我使用什么样的命名空间? 2.如何声明GridLength StaticResource? 3.我是否正确使用属性?我在文档中找到它,但不知道如何正确使用它。
[在WPF中指定宽度/高度作为资源]的可能副本(http://stackoverflow.com/questions/2279732/specify-width-height-as-resource-in-wpf) –
本节解释如何定义GridLength资源:http://stackoverflow.com/a/18637378/1023619 – lexa
您不需要任何名称空间。只是' 50 '什么是'property =“doubleLength”'所有关于? –