0

I'm trying to implement a custom popup menu for one of my app bar icon button (something like the PhoneFlipMenu tool). I'm using a vertical StackPanel for that:

<StackPanel x:Name="popupMenuListCommands" Grid.Row="1" 
            Orientation="Vertical" VerticalAlignment="Bottom" 
            Background="{StaticResource PhoneDisabledBrush}"
            Visibility="Collapsed">
    <TextBlock Text="menu item 1" Style="{StaticResource PopupMenuListCommand}" />
    <TextBlock Text="menu item 2" Style="{StaticResource PopupMenuListCommand}" />
</StackPanel>

It is shown when the user presses the app bar button:

void appBarIconButtonList_Click(object sender, EventArgs e)
{
    popupMenuListCommands.Visibility = Visibility.Visible;
    ApplicationBar.IsVisible = false;
}

There are 2 problems:

1) How can I retrieve the effective color of the application bar to use it in my stack panel? ApplicationBar.BackgroundColor returns #00000000, but obviously the effective color of the app bar background is not this. For instance, it is a dark gray when the dark phone theme is on.

If we cannot retrieve this color dynamically, perhaps, we just need to hard code 2 color values for the dark and white themes. Then the question is what are their values?

2) How to use the color retrieved on the previous step to make the stack panel non-transparent? Now I see the main content under it even if I specify the background brush explicitly.

4

2 回答 2

1

应用栏根据主题使用默认手机颜色。那么,为什么不使用默认主题颜色而不是使用应用栏颜色呢?这也会做同样的事情。http://www.jeff.wilcox.name/2012/01/phonethememanager/这将对您有所帮助。

对于深色主题,颜色为 rgb (31, 31, 31)。对于浅色主题,颜色为 rgb (221,221,221)。

希望这有帮助。干杯

于 2014-06-03T12:44:16.183 回答
0

您可以从名为“PhoneChromeBrush”的应用程序资源中获取应用程序栏颜色。因此,您需要做的就是将堆栈面板背景设置为此画笔。

    <StackPanel x:Name="popupMenuListCommands" Grid.Row="1" 
        Orientation="Vertical" VerticalAlignment="Bottom" 
        Background="{StaticResource PhoneChromeBrush}"
        Visibility="Collapsed">
<TextBlock Text="menu item 1" Style="{StaticResource PopupMenuListCommand}" />
<TextBlock Text="menu item 2" Style="{StaticResource PopupMenuListCommand}" />

这样您就不必担心手机的深色或浅色主题。

于 2014-06-03T14:31:08.110 回答