ピボット ページを使用するアプリケーションを開発しています。
スタイル「PageBackgroundStyle」で定義された背景を使用して、デフォルトの Pivot テンプレートを使用してアプリケーションを作成しました。
<phone:PhoneApplicationPage x:Class="PivotApp.Views.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait"
Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot"
Style="{StaticResource PageBackgroundStyle}">
<phone:Pivot x:Name="LocationPivot"
FontSize="{StaticResource LargeFontSize}"
LoadedPivotItem="Pivot_LoadedPivotItem">
<phone:Pivot.Title>
<TextBlock Text="Title"
FontSize="20"
Margin="0,0,0,10" />
</phone:Pivot.Title>
<phone:PivotItem x:Name="one">
<phone:PivotItem.Header>
<TextBlock Text="one"
FontSize="50" />
</phone:PivotItem.Header>
<Grid />
</phone:PivotItem>
<phone:PivotItem x:Name="two">
<phone:PivotItem.Header>
<TextBlock Text="two"
FontSize="50" />
</phone:PivotItem.Header>
<Grid />
</phone:PivotItem>
<phone:PivotItem x:Name="three">
<phone:PivotItem.Header>
<TextBlock Text"three"
FontSize="50" />
</phone:PivotItem.Header>
<Grid />
</phone:PivotItem>
</phone:Pivot>
</Grid>
</phone:PhoneApplicationPage>
アプリケーションは (OnNavigatedTo 内で) GetGeopositionAsync() メソッドを呼び出します。上記のコードは正常に動作します。
ただし、次のように画像の背景を表示するようにコードを変更すると、次のようになります。
<phone:PhoneApplicationPage x:Class="PivotApp.Views.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait"
Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot">
<Grid.Background>
<ImageBrush Stretch="Fill"
ImageSource="/PivotApp;component/Assets/PanoramaBackground.png" />
</Grid.Background>
<phone:Pivot x:Name="LocationPivot"
FontSize="{StaticResource LargeFontSize}"
LoadedPivotItem="Pivot_LoadedPivotItem">
<phone:Pivot.Title>
<TextBlock Text="Title"
FontSize="20"
Margin="0,0,0,10" />
</phone:Pivot.Title>
<phone:PivotItem x:Name="one">
<phone:PivotItem.Header>
<TextBlock Text="one"
FontSize="50" />
</phone:PivotItem.Header>
<Grid />
</phone:PivotItem>
<phone:PivotItem x:Name="two">
<phone:PivotItem.Header>
<TextBlock Text="two"
FontSize="50" />
</phone:PivotItem.Header>
<Grid />
</phone:PivotItem>
<phone:PivotItem x:Name="three">
<phone:PivotItem.Header>
<TextBlock Text"three"
FontSize="50" />
</phone:PivotItem.Header>
<Grid />
</phone:PivotItem>
</phone:Pivot>
</Grid>
</phone:PhoneApplicationPage>
つまり、スタイルで背景を定義する代わりに、PageBackGroundStyle (App.xaml で定義) に次のコードを入力します。
<Grid.Background>
<ImageBrush Stretch="Fill"
ImageSource="/PivotApp;component/Assets/PanoramaBackground.png" />
</Grid.Background>
画像の背景はピボット ページに表示されますが、GetGeopositionAsync() メソッドが呼び出されて戻りません。
私が何か間違ったことをしている、またはピボット/ページに問題があるかどうか、何か考えはありますか? どうも