Skip to content

Instantly share code, notes, and snippets.

@tmyt tmyt/MainPage.xaml
Created Oct 25, 2012

Embed
What would you like to do?
AttachedPropertyに設定される値がFrameworkElementを継承していない場合にUri型に値を設定できない?
<Page
x:Class="App1.MainPage"
IsTabStop="false"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
</Grid>
<local:Container.c1>
<local:c1 uri="http://www.example.com/" />
</local:Container.c1>
<local:Container.c2>
<local:c2 uri="http://www.example.com/" />
</local:Container.c2>
</Page>
using Windows.UI.Xaml.Controls;
namespace App1
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
}
public class c1
{
public Uri uri { get; set; }
}
public class c2 : FrameworkElement
{
public c2(){}
public Uri uri { get; set; }
}
public class Container
{
public static c1 Getc1(DependencyObject obj)
{
return (c1)obj.GetValue(c1Property);
}
public static void Setc1(DependencyObject obj, c1 value)
{
obj.SetValue(c1Property, value);
}
public static c2 Getc2(DependencyObject obj)
{
return (c2)obj.GetValue(c2Property);
}
public static void Setc2(DependencyObject obj, c2 value)
{
obj.SetValue(c2Property, value);
}
public static readonly DependencyProperty c1Property =
DependencyProperty.RegisterAttached("c1", typeof(c1), typeof(Container), new PropertyMetadata(null));
public static readonly DependencyProperty c2Property =
DependencyProperty.RegisterAttached("c2", typeof(c2), typeof(Container), new PropertyMetadata(null));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.