Skip to content

Instantly share code, notes, and snippets.

Created March 26, 2012 02:45
Show Gist options
  • Save anonymous/2202554 to your computer and use it in GitHub Desktop.
Save anonymous/2202554 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"
>
<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);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment