我試圖創建一個類型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」'所有關於? –