tmytのらくがき

個人の日記レベルです

Win10で動くWinRT(8.1)のへんな挙動

次のコードをWindows8.1向けにビルドして、Windows10上で動かすとなぜかテーマが動的にLightで上書きされます。

<Page
    x:Class="App15.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App15"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Button Content="TestButton">
            <Button.Flyout>
                <MenuFlyout>
                    <MenuFlyoutItem Text="Menu Item" x:Name="MenuItem" />
                </MenuFlyout>
            </Button.Flyout>
        </Button>
    </Grid>
</Page>
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace App15
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
            MenuItem.DataContext = this;
        }
    }
}

ボタンを押す前

f:id:tmyt:20150808181939p:plain

ボタンを押したあと

f:id:tmyt:20150808181951p:plain

回避方法

DataContext = this; を使わない