Skip to content

Instantly share code, notes, and snippets.

@ritalin
Forked from anonymous/BlankPage.xaml
Created March 26, 2012 04:02
Show Gist options
  • Save ritalin/2202873 to your computer and use it in GitHub Desktop.
Save ritalin/2202873 to your computer and use it in GitHub Desktop.
For metro style app, unable to use attachable property defined by other assembly.
<!--
<Page
x:Class="APTest.App.BlankPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:APTest.App"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:fw="clr-namespace:AP.Framework;assembly=AP.Framework"
>
-->
<Page
x:Class="APTest.App.BlankPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:APTest.App"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:fw="using:AP.Framework"
>
<Grid Background="{StaticResource ApplicationPageBackgroundBrush}" x:Name="ContentRoot">
<Button x:Name="btn1" Content="ABC" fw:TestBehaviour.Num="200" />
</Grid>
</Page>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
namespace AP.Framework {
public static class TestBehaviour {
public static readonly DependencyProperty NumProperty = DependencyProperty.RegisterAttached(
"Num",
typeof(int),
typeof(TestBehaviour),
new PropertyMetadata(100)
);
public static int GetNum(UIElement d) {
return (int)d.GetValue(NumProperty);
}
public static void SetNum(UIElement d, int value) {
d.SetValue(NumProperty, value);
}
}
}
@ritalin
Copy link
Author

ritalin commented Mar 26, 2012

modified declalation of external assembly namespace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment