2015-12-04 11 views
11

Sto provando ad accedere allo spazio dei nomi di sistema per le variabili StaticResource in XAML su UWP. Ecco (per lo più) quello che sto usando:Come si dichiara un tipo di dati di sistema 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> 

Anche se i <System:Double ...> spettacoli in IntelliSense come valido, sto ottenendo il seguente errore di runtime:

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]

Sono aperto ad altri modi di dichiarare un doppio se questo metodo non funziona.

risposta

22

Risulta essere nello spazio dei nomi predefinito x:.

<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> 
Problemi correlati