This project is read-only.

Using AppBarUtils in MultiLanguage AppBar

Apr 16, 2012 at 2:25 PM

Hello,

I discovered your dll and think that it's a nice thing. But it has one weakness. Binding to the Text-Property brings some problems.

 

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="Setup"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
    
    <i:Interaction.Behaviors>
        <AppBar:AppBarItemCommand  Id="Setup" Text="{Binding Source={StaticResource GlobalResources}, Path=AppBar_Setup}" Type="MenuItem" Command="{Binding Source={StaticResource MyJobTasksViewModel}, Path=NavigateToSetup}" />
    </i:Interaction.Behaviors>
    
    <i:Interaction.Triggers>
        <AppBar:AppBarItemTrigger Type="MenuItem" Id="Setup">
            <AppBar:NavigateWithQueryStringAction TargetPage="/View/SetupView.xaml"/>
        </AppBar:AppBarItemTrigger>
    </i:Interaction.Triggers>

The name of my Button is translated to German with the Binding in the Interaction.Behaviors Trigger. So you can't access the Interatcion.Triggers because the ID or the Text in MenuItem has changed. Has anyone a solution for my problem?

 

Thank you.  


Apr 18, 2012 at 2:54 PM

Hi there,

Looks like you want more than one actions for the same app bar item? In this case, you can put multiple actions inside one AppBarItemTrigger like:

    <i:Interaction.Triggers>
        <AppBar:AppBarItemTrigger Type="MenuItem" Id="Setup" Text="{Binding Source={StaticResource GlobalResources}, Path=AppBar_Setup}">
            <InvokeCommandAction Command="{Binding Source={StaticResource MyJobTasksViewModel}, Path=NavigateToSetup}"/>
            <AppBar:NavigateWithQueryStringAction TargetPage="/View/SetupView.xaml"/>
        </AppBar:AppBarItemTrigger>
    </i:Interaction.Triggers>
The trick here is to use InvokeCommandAction provided by Expression Blend SDK instead of AppBarItemCommand, and let AppBarItemTrigger do the Text binding for you.

Thanks/Allen