【发布时间】:2011-11-14 21:22:54
【问题描述】:
我正在创建带有附加属性的行为。行为应附加到网格:
public class InteractionsBehavior : Behavior<Grid>
{
public static readonly DependencyProperty ContainerProperty =
DependencyProperty.RegisterAttached("Container", typeof(Grid), typeof(Grid), new PropertyMetadata(null));
public static readonly DependencyProperty InteractionsProviderProperty =
DependencyProperty.RegisterAttached("InteractionsProvider", typeof(IInteractionsProvider), typeof(Grid), new PropertyMetadata(null, OnInteractionsProviderPropertyChanged));
public Grid Container
{
get { return GetValue(ContainerProperty) as Grid; }
set { this.SetValue(ContainerProperty, value); }
}
public IInteractionsProvider InteractionsProvider
{
get { return GetValue(InteractionsProviderProperty) as IInteractionsProvider; }
set { this.SetValue(InteractionsProviderProperty, value); }
}
现在当我像这样编写 XAML 时出现错误:
<Grid Background="White" x:Name="LayoutRoot"
Behaviors:InteractionsBehavior.InteractionsProvider="{Binding InteractionsProvider}">
错误 4 类型上不存在属性“InteractionsProvider” XML 命名空间中的“网格” 'clr-命名空间:Infrastructure.Behaviors;assembly=Infrastructure.SL'。 C:\MainPage.xaml 11 11 Controls.SL.Test
错误 1 未找到可附加属性“InteractionsProvider” 在类型 '交互行为'。 C:\MainPage.xaml 11 11 Controls.SL.Test
【问题讨论】:
标签: c# silverlight xaml behavior