How do I declare a System data type in UWP/RT XAML?
Asked Answered
M

1

16

I'm trying to access the system namespace for StaticResource variables in XAML on UWP. Here's (mostly) what I'm using:

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

Even though the <System:Double ...> shows in IntelliSense as valid, I'm getting the following runtime error:

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]

I'm open to other ways of declaring a double if this method will not work.

Marche answered 4/12, 2015 at 18:7 Comment(0)
M
26

Turns out it's in the default 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>
Marche answered 4/12, 2015 at 20:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.