I want to define a byte type dp in a windows store app project, but got a runtime error like this:
An exception of type 'Windows.UI.Xaml.Markup.XamlParseException' occurred in App6.exe but was not handled in user code
WinRT information: Cannot deserialize XBF metadata property list as 'Id' was not found in type 'null'. [Line: 0 "text-decoration:underline;">Additional information: The text associated with this error code could not be found.
Is this a bug or something I am not aware of?(I am using vs2013 and WinRT8.1)
Here is the source code:
[MainPage.cs]
namespace App1
{
public sealed class MyClass2
{
public byte Id { get; set; }
}
public sealed class MyClass: DependencyObject
{
public byte Id
{
get { return (byte)GetValue(IdProperty); }
set { SetValue(IdProperty, value); }
}
public static readonly DependencyProperty IdProperty =
DependencyProperty.Register("Id", typeof(byte), typeof(MyClass), new PropertyMetadata(0));
}
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
}
}
[MainPage.xaml]
<Page
x:Class="App1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App6"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<local:MyClass2 x:Key="MyObj2" />
<local:MyClass x:Key="MyObj"
Id="{Binding Id, Source={StaticResource MyObj2}}"/>
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
</Grid>
</Page>
No comments:
Post a Comment