Silverlight AG_E_解析器_BAD_属性_值[行:50位置:45]

Silverlight AG_E_解析器_BAD_属性_值[行:50位置:45],silverlight,windows-phone-7,Silverlight,Windows Phone 7,这是我的ApplicationBar代码(由于数据绑定而导致错误的代码) 在construtor中,我有一行:- this.DataContext = this; 装订不正常,但我不知道为什么!我知道INotifyPropertyChanged不能很好地将WP7作为Silverlight 4.0使用。但我已经有了财产。我还能为此做些什么 提前感谢:)应用程序栏作为控件有点奇怪。。。看到这个帖子了吗 我认为,因为ApplicationBar不是一个框架元素,所以不能在其中绑定数据—类似于Dere

这是我的ApplicationBar代码(由于数据绑定而导致错误的代码)

在construtor中,我有一行:-

this.DataContext = this;
装订不正常,但我不知道为什么!我知道INotifyPropertyChanged不能很好地将WP7作为Silverlight 4.0使用。但我已经有了财产。我还能为此做些什么


提前感谢:)

应用程序栏作为控件有点奇怪。。。看到这个帖子了吗

我认为,因为ApplicationBar不是一个框架元素,所以不能在其中绑定数据—类似于Derek对它的回答


很抱歉,您可能需要在CodeBehind中调整应用程序栏,而不是通过数据绑定-请参见

-如何在代码中调整它?当我在MainPage.xaml.cs的加载事件中访问这个愚蠢的控件(previItem)时,我得到Null。你能解释一下在加载的事件中它怎么可能是空的吗?请看我链接的问题中的答案-你不能使用名称-你总是需要使用数组索引访问,比如
(iaapplicationbariconbutton)ApplicationBar。按钮[2]
-可能没有数据绑定那么好,但你必须笑着接受它。
public static readonly DependencyProperty PreviousTopicProperty = DependencyProperty.Register("PreviousTopic",
    typeof(Topic), typeof(ArticleViewer), new PropertyMetadata(null));
public Topic PreviousTopic
{
    get { return GetValue(PreviousTopicProperty) as Topic; }
    set
    {

        SetValue(PreviousTopicProperty, value);
    }
}

public static readonly DependencyProperty NextTopicProperty = DependencyProperty.Register("NextTopic",
    typeof(Topic), typeof(ArticleViewer), new PropertyMetadata(null));
public Topic NextTopic
{
    get { return GetValue(NextTopicProperty) as Topic; }
    set
    {

        SetValue(NextTopicProperty, value);
    }
}

public static readonly DependencyProperty IsNextTopicButtonEnabledProperty = DependencyProperty.Register("IsNextTopicButtonEnabled",
    typeof(bool), typeof(ArticleViewer), new PropertyMetadata(true));
public bool IsNextTopicButtonEnabled
{
    get { return (bool)GetValue(IsNextTopicButtonEnabledProperty); }
    set
    {

        SetValue(IsNextTopicButtonEnabledProperty, value);
    }
}

public static readonly DependencyProperty IsPrevTopicButtonEnabledProperty = DependencyProperty.Register("IsPrevTopicButtonEnabled",
typeof(bool), typeof(ArticleViewer), new PropertyMetadata(true));
public bool IsPrevTopicButtonEnabled
{
    get { return (bool)GetValue(IsPrevTopicButtonEnabledProperty); }
    set
    {

        SetValue(IsPrevTopicButtonEnabledProperty, value);
    }
}
this.DataContext = this;