开发者

AG_E_PARSER_BAD_PROPERTY_VALUE [Line: 50 Position: 45]

开发者 https://www.devze.com 2023-03-02 12:52 出处:网络
This is my code of ApplicationBar (The code which is causing error due to databinding) <phone:PhoneApplicationPage.ApplicationBar>

This is my code of ApplicationBar (The code which is causing error due to databinding)

 <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" >
            <shell:ApplicationBarIconB开发者_JAVA百科utton IconUri="/icons/prevItem.png" x:Name="prevItem"
                                            IsEnabled="{Binding Path=IsPrevTopicButtonEnabled}"
                                            Text="Prev item" Click="prevItem_Click">

            </shell:ApplicationBarIconButton>
            <shell:ApplicationBarIconButton IconUri="/icons/nextItem.png" 
                                            IsEnabled="{Binding Path=IsNextTopicButtonEnabled}"
                                            Text="Next item" x:Name="nextItem" Click="nextItem_Click"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem x:Name="mnuPrevItem" Text="{Binding Path=PreviousTopic.Title}"/>
                <shell:ApplicationBarMenuItem x:Name="mnuNextItem" Text="{Binding Path=NextTopic.Title}"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

These are my properties in code-behind :-

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

In the construtor I have this line:-

this.DataContext = this;

The binding is not working properly but I have no idea Why! I know INotifyPropertyChanged doesn't quiet work well with WP7 as Silverlight 4.0. But I already have DependencyProperties. What more can I do for this?

Thanks in advance :)


ApplicationBar is a bit odd as a control... see this post "Why application bar is not a FrameworkElement?"

I think because the ApplicationBar is not a FrameworkElement you can't data bind within it - similar to Derek's answer to Getting AG_E_PARSER_BAD_PROPERTY_VALUE while data binding in WP7 User control

I'm sorry to say that you may just have to adjust the ApplicationBar in CodeBehind rather than through databinding - see Change applicationbar buttonicon at runtime

0

精彩评论

暂无评论...
验证码 换一张
取 消