Frage

following Code...

<!--Navigation-Bar-->
<phone:PhoneApplicationPage.ApplicationBar>
    <shell:ApplicationBar IsVisible="True" ForegroundColor="White" IsMenuEnabled="True" BackgroundColor="#002B55">
        <shell:ApplicationBarIconButton Click="B_Search_Click" IconUri="Images\Pic_Search.png" Text="Search"/>
        <shell:ApplicationBarIconButton Click="B_Media_Click" IconUri="Images\Pic_Media.png" Text="Media"/>
        <shell:ApplicationBarIconButton Click="B_Scan_Click" IconUri="Images\Pic_Scan.png" Text="Scanner"/>
        <shell:ApplicationBarIconButton Click="B_Charts_Click" IconUri="Images\Pic_Charts.png" Text="Charts"/>
        <shell:ApplicationBar.MenuItems>
            <shell:ApplicationBarMenuItem Click="B_Logout_Click" Text="Logout"/>
        </shell:ApplicationBar.MenuItems>
    </shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

gives me following ApplicationBar...

http://s14.directupload.net/file/d/3341/4xiadbvz_jpg.htm (Solid background when expanded)

BUT if I create the AppBar in CodeBehind like this...

 private void ResetApplicationBar()
        {
            ApplicationBar = new ApplicationBar();
            ApplicationBar.BackgroundColor = Color.FromArgb(150, 0, 43, 85);;
            ApplicationBar.ForegroundColor = Colors.White;
            ApplicationBar.Opacity = 1;

            ApplicationBarIconButton B_Search = new ApplicationBarIconButton();
            B_Search.IconUri = new Uri("/Images/Pic_Search.png", UriKind.Relative);
            B_Search.Text = "search";
            ApplicationBar.Buttons.Add(B_Search);
            B_Search.Click += new EventHandler(B_Search_Click);

            (more Buttons...)

then I get that misterios unchangable Transparency...

http://s1.directupload.net/file/d/3341/zjo57e37_jpg.htm (Half-Transparent when expanded)

How can I change the Background to solid??? -Yes I have mostly overwritten the theme -Changing global colors doesnt work -changing background/foreground doesnt work -changing opacity doesnt work...

I need to generate it from code behind because im changing it dynamically in one window (or is it possible to define multiple AppBars in markup?)

Thanks in advance!

War es hilfreich?

Lösung 3

Thank you very much for effort, but changing opacity didnt to 0.999 didnt help either.

I found a solution!! And its quite simple :)

I Just take the old bar instead of creating a new one:

//Old Code
    ApplicationBar = new ApplicationBar();

//New Code
    ApplicationBar.Buttons.Clear();
    ApplicationBar.MenuItems.Clear();

Hope it helps someone!

Andere Tipps

Please try this one

ApplicationBar.BackgroundColor = Color.FromArgb(52,0,2,181);
ApplicationBar.ForegroundColor = Colors.White;

You will get the same color in designer page by this way.

This (52,0,2,181) is the conversion value of #002B55

On a fresh project, everything seems fine, here.

"- changing background/foreground doesnt work 
 - changing opacity doesnt work..."

Using the Application Bar sample, you provided in XAML, but with Opacity=0.5, I get this :

your XAML AppBar but with Opac

After I click the "Change Color" button, which does ApplicationBar.Opacity = 1;, I get this result :

enter image description here

(The background image is slightly moved up, because in first case we provided an opacity and in the second there was none explicitly specified and it seems the app bar didn't layered over the image, but to fix this you can set an Opacity=0.999, close to 1).

It must have something to do with all the theme overwriting you have done or some customization you attempted.

If this isn't quite helpful, provide me more details and I'll try to help as I can.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top