如何在UWP/RT XAML中声明系统数据类型?

Nop*_*det 15 c# xaml winrt-xaml uwp windows-10-universal

我正在尝试在UWP上的XAML中访问StaticResource变量的系统命名空间.这是(大部分)我正在使用的:

<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>
Run Code Online (Sandbox Code Playgroud)

即使<System:Double ...>IntelliSense中的节目有效,我也会遇到以下运行时错误:

类型的异常"Windows.UI.Xaml.Markup.XamlParseException"发生在mscorlib.ni.dll但在用户代码中没有处理

WinRT信息:无法反序列化XBF元数据类型列表,因为在命名空间"System"中找不到"Double".[线:0位置:0]

如果这种方法不起作用,我会对其他声明双重的方式持开放态度.

Nop*_*det 25

原来它在默认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>
Run Code Online (Sandbox Code Playgroud)