2015-12-04 14 views
11

Ich versuche, den System-Namespace für StaticResource-Variablen in XAML auf UWP zuzugreifen. Hier ist (meistens), was ich verwende:Wie deklariere ich einen Systemdatentyp in UWP/RT XAML?

<Page 
    x:Class="App.UWP.Views.Step6" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:System="using:System" 
    mc:Ignorable="d"> 

    <Page.Resources> 
     <System:Double x:Key="ItemNameWidth">260</System:Double> 
    </Page.Resources> 

    <TextBlock FontSize="16" Width="{StaticResource ItemNameWidth}">foo</TextBlock> 
</page> 

Obwohl die <System:Double ...> zeigt in IntelliSense als gültig, ich bin die folgenden Laufzeitfehler erhalten:

An exception of type 'Windows.UI.Xaml.Markup.XamlParseException' occurred in mscorlib.ni.dll but was not handled in user code

WinRT information: Cannot deserialize XBF metadata type list as 'Double' was not found in namespace 'System'. [Line: 0 Position: 0]

ich andere offen bin Möglichkeiten, ein Double zu deklarieren, wenn diese Methode nicht funktioniert.

Antwort

22

Stellt sich heraus, es ist in der Standardeinstellung x: Namespace.

<Page 
    x:Class="App.UWP.Views.Step6" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:System="using:System" 
    mc:Ignorable="d"> 

    <Page.Resources> 
     <x:Double x:Key="ItemNameWidth">260</x:Double> 
    </Page.Resources> 

    <TextBlock FontSize="16" Width="{StaticResource ItemNameWidth}">foo</TextBlock> 
</page>