Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 310
Noppadet Avatar asked Dec 04 '15 18:12

Noppadet


People also ask

Does UWP use XAML?

Topics in this section also document the XAML language as it's used by the UWP and basic to advanced scenarios about how to use XAML to define the UI for your UWP app.

How do I show pop up in UWP?

To show a Popup, set its IsOpen property to true. To hide the Popup, set IsOpen to false. You can set IsLightDismissEnabled to make the Popup hide automatically when a user taps anywhere away from it.

What is binding in UWP?

Binding to a single item. Every binding consists of a binding target and a binding source. Typically, the target is a property of a control or other UI element, and the source is a property of a class instance (a data model, or a view model). This example shows how to bind a control to a single item.


1 Answers

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>
like image 183
Noppadet Avatar answered Sep 25 '22 21:09

Noppadet