Hello,
I have a xaml file in my Assets folder "MainPage1.xaml" defined as below.
<StackPanel
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:local="using:Label"
>
<Grid local:PageControl.PageHeight="10">
</Grid>
</StackPanel>
Next, I am trying to load this file to my app using XAMLReader
private async void Page_Loaded(object sender, RoutedEventArgs e)
{
var folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync(@"Assets");
string xamlDefinition = await Windows.Storage.FileIO.ReadTextAsync(await folder.GetFileAsync("MainPage1.xaml"));
var xamlElement = ((FrameworkElement)XamlReader.Load(xamlDefinition));
}
I get such error:
Windows.UI.Xaml.Markup.XamlParseException:
The attachable property 'PageHeight' was not found in type 'PageControl'. [Line: 5 Position: 11]”
PageControl class is defined as below:
public class PageControl : DependencyObject
{
public static readonly DependencyProperty PageHeightProperty = DependencyProperty.RegisterAttached( "PageHeight",
typeof(double),
typeof(PageControl),
new PropertyMetadata(default(double))
);
public static void SetPageHeight(UIElement element, double value)
{
element.SetValue(PageHeightProperty, value);
}
public static double GetPageHeight(UIElement element)
{
return (double)element.GetValue(PageHeightProperty);
}
}//END PageControl
I did some tests and behavior of this issue is strange:
If, I move the code to newly created app this code works.
In previous version of my app this code was working.
In debug mode it works, in release mode it doesnt work.
My app is too big to share it, so please guess where problem can lies.