Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 默认值不能为';取消设置';_C#_Wpf_Xaml_Attached Properties - Fatal编程技术网

C# 默认值不能为';取消设置';

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

当我将此附加到xaml元素时,我有一个附加属性,它被称为“默认值不能是'Unset'

我的附加属性逻辑

    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));