【问题标题】:appbar windows phone 8 mvvmappbar windows phone 8 mvvm
【发布时间】:2012-12-04 14:53:49
【问题描述】:

那么,我的 manipange.xaml 、应用程序栏声明和按钮声明/定义中都有类似的内容

<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar x:Name="xxxx" IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton
                x:Name="appBarRegisterButton"
                IconUri="/Images/next.png"
                Text="Login"
                Click="appBarRegisterButton_Click_1" IsEnabled="True"/>
            </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

当我尝试更改其他模型的某些属性时,fe。 这是我的注册模型。

   public RegisterViewModel()
    {
        RegisterTitle = Resources.AppResources.RegisterTitle;
        Messenger.Default.Register<RegisterButtonPressed>(this, msg => AttemptToRegister(msg.reg));
    }


    private void AttemptToRegister(Register reg)
    {
        reg.appBarRegisterButton.IsEnabled = true;
     }

它没有改变,更好的是我的注册按钮是一个空对象,有人知道如何解决这个问题吗? ;/

【问题讨论】:

    标签: mvvm-light windows-phone-8 mvvm-toolkit


    【解决方案1】:

    您必须像这样访问按钮:

    var applicationBarIconButton = ApplicationBar.Buttons[0] as ApplicationBarIconButton;
    if (applicationBarIconButton != null)
          {
    //do stuff
    }
    

    索引取决于它在应用栏中的位置。

    【讨论】:

    • 谢谢老兄,你救了我的命; )
    猜你喜欢
    • 2012-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-13
    • 1970-01-01
    • 1970-01-01
    • 2012-08-24
    • 1970-01-01
    相关资源
    最近更新 更多