无法在“DictionaryEntry”类型的“Value”属性上设置“绑定”

时间:2013-11-30 13:11:39

标签: c# .net wpf wpf-controls

这是我的代码,

我的自定义类:ministView

public class MiniListView : ListView
{
   public static DependencyProperty HeadersProperty;
   public Dictionary<string, string> Headers
   {
      get { return (Dictionary<string, string>)base.GetValue(HeadersProperty); }
      set { base.SetValue(HeadersProperty, value); }
   }
   public MiniListView()
    {
        HeadersProperty = DependencyProperty.Register("Headers", typeof(Dictionary<string, string>), typeof(MiniListView ));
        this.View = MyGrid();
    }
}

用户控件

    <StackPanel HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,43,43,0">
        <mine:MiniListView x:Name="Mini" Width="300" Headers="{Binding MyHeaders}"></mine:MiniListView>
        <Button HorizontalAlignment="Right" Margin="0" FontSize="10" Content="Add Row" Width="70" Height="20" />
    </StackPanel>

守则背后:

    public Dictionary<string, string> MyHeaders
    {
        get
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("NAME", "BRANCH"); dic.Add("BANKNAME", "Percentage");
            return dic;
        }
    }

在这里,我试图将MyHeaders绑定到HEADER'S PROPERTY,收到此错误

  

无法在“DictionaryEntry”类型的“Value”属性上设置“绑定”。 '绑定'只能在DependencyObject的DependencyProperty上设置。

请告诉我我的代码有什么问题。

谢谢,

0 个答案:

没有答案