C# 默认值不能为';取消设置';
当我将此附加到xaml元素时,我有一个附加属性,它被称为“默认值不能是'Unset' 我的附加属性逻辑C# 默认值不能为';取消设置';,c#,wpf,xaml,attached-properties,C#,Wpf,Xaml,Attached Properties,当我将此附加到xaml元素时,我有一个附加属性,它被称为“默认值不能是'Unset' 我的附加属性逻辑 public static DataTemplate GetFooterContentTemplate(DependencyObject obj) { return (DataTemplate)obj.GetValue(FooterContentTemplateProperty); } public static void SetFooterC
public static DataTemplate GetFooterContentTemplate(DependencyObject obj)
{
return (DataTemplate)obj.GetValue(FooterContentTemplateProperty);
}
public static void SetFooterContentTemplate(DependencyObject obj, DataTemplate value)
{
obj.SetValue(FooterContentTemplateProperty, value);
}
// Using a DependencyProperty as the backing store for GetFooterContentTemplate. This enables animation, styling, binding, etc...
public static readonly DependencyProperty FooterContentTemplateProperty =
DependencyProperty.Register("FooterContentTemplate", typeof(DataTemplate), typeof(RadWindowFooterProperties), new PropertyMetadata(DependencyProperty.UnsetValue));
public static Object GetFooterContent(DependencyObject obj)
{
return (Object)obj.GetValue(FooterContentProperty);
}
public static void SetFooterContent(DependencyObject obj, Object value)
{
obj.SetValue(FooterContentProperty, value);
}
// Using a DependencyProperty as the backing store for RadWindowFooterContent. This enables animation, styling, binding, etc...
public static readonly DependencyProperty FooterContentProperty =
DependencyProperty.RegisterAttached("FooterContent", typeof(Object), typeof(RadWindowFooterProperties), new PropertyMetadata(DependencyProperty.UnsetValue));
我的XAML:
<Grid x:Name="FooterRoot" Grid.Row="2" MinHeight="42">
<Border Background="{StaticResource ShellFooterBrush}"/>
<Border Background="{DynamicResource ShellTileBrush}"/>
<ContentPresenter Content="{Binding Path=(Local:RadWindowFooterProperties.FooterContent),RelativeSource={RelativeSource Mode=TemplatedParent}}" ContentTemplate="{Binding Path=(Local:RadWindowFooterProperties.FooterContentTemplate),RelativeSource={RelativeSource Mode=TemplatedParent}}" RecognizesAccessKey="True"/>
</Grid>
请告诉我哪里出了错。如果我读对了,它会说:
特别禁止将DefaultValue设置为UnsetValue
因此,我建议设置一个默认值,如null
或任何更适合您的用例的值。如果我读得正确,它会说明:
特别禁止将DefaultValue设置为UnsetValue
因此,我建议设置一个默认值,如null
或任何更适合您的用例的值。如果我读得正确,它会说明:
特别禁止将DefaultValue设置为UnsetValue
因此,我建议设置一个默认值,如null
或任何更适合您的用例的值。如果我读得正确,它会说明:
特别禁止将DefaultValue设置为UnsetValue
因此,我建议设置一个默认值,如
null
或任何更适合您的用例的值。DependencyProperty。UnsetValue
不是依赖属性的有效默认值。除非要指定除null
之外的默认值,否则根本不需要注册属性元数据
您还必须将FooterContentTemplateProperty
的声明更改为使用RegisterAttached
而不是Register
:
public static readonly DependencyProperty FooterContentTemplateProperty =
DependencyProperty.RegisterAttached(
"FooterContentTemplate", typeof(DataTemplate), typeof(RadWindowFooterProperties));
public static readonly DependencyProperty FooterContentProperty =
DependencyProperty.RegisterAttached(
"FooterContent", typeof(Object), typeof(RadWindowFooterProperties));
DependencyProperty.UnsetValue
不是依赖项属性的有效默认值。除非要指定除null
之外的默认值,否则根本不需要注册属性元数据
您还必须将FooterContentTemplateProperty
的声明更改为使用RegisterAttached
而不是Register
:
public static readonly DependencyProperty FooterContentTemplateProperty =
DependencyProperty.RegisterAttached(
"FooterContentTemplate", typeof(DataTemplate), typeof(RadWindowFooterProperties));
public static readonly DependencyProperty FooterContentProperty =
DependencyProperty.RegisterAttached(
"FooterContent", typeof(Object), typeof(RadWindowFooterProperties));
DependencyProperty.UnsetValue
不是依赖项属性的有效默认值。除非要指定除null
之外的默认值,否则根本不需要注册属性元数据
您还必须将FooterContentTemplateProperty
的声明更改为使用RegisterAttached
而不是Register
:
public static readonly DependencyProperty FooterContentTemplateProperty =
DependencyProperty.RegisterAttached(
"FooterContentTemplate", typeof(DataTemplate), typeof(RadWindowFooterProperties));
public static readonly DependencyProperty FooterContentProperty =
DependencyProperty.RegisterAttached(
"FooterContent", typeof(Object), typeof(RadWindowFooterProperties));
DependencyProperty.UnsetValue
不是依赖项属性的有效默认值。除非要指定除null
之外的默认值,否则根本不需要注册属性元数据
您还必须将FooterContentTemplateProperty
的声明更改为使用RegisterAttached
而不是Register
:
public static readonly DependencyProperty FooterContentTemplateProperty =
DependencyProperty.RegisterAttached(
"FooterContentTemplate", typeof(DataTemplate), typeof(RadWindowFooterProperties));
public static readonly DependencyProperty FooterContentProperty =
DependencyProperty.RegisterAttached(
"FooterContent", typeof(Object), typeof(RadWindowFooterProperties));