9

アプリ内のすべてのアイテム ヘッダーに使用できるように、パノラマ アイテム ヘッダーのフォント サイズを一度に設定する最も簡単な方法は何ですか?

4

4 に答える 4

23

アプリ内のすべてのヘッダーに対して自動的にそれを行う方法はまだありません。それぞれのスタイルを設定する必要があります。

暗黙のスタイリングがMangoアップデートで提供されており、これにより、これを実行できるようになります。

更新
これがあなたが今できることです。

必要なFontSzieのグローバルテンプレートスタイルを作成します。何かのようなもの:

<Application.Resources>
    <DataTemplate x:Key="MyItemHeaderTemplate">
        <Grid>
            <ContentPresenter>
                <TextBlock Text="{Binding}" FontSize="20" />
            </ContentPresenter>
        </Grid>
    </DataTemplate>
</Application.Resources>

次に、この方法でスタイルを設定したいすべてのPanoramaItemで、HeaderTemplateを設定します。

<controls:PanoramaItem Header="first" HeaderTemplate="{StaticResource MyItemHeaderTemplate}">
    // ...
</controls:PanoramaItem>
于 2011-05-16T14:53:22.493 に答える
5

これは私にとっても難しい問題でした。ただし、サイズ変更/フォントの太さ/フォントなどを変更したいヘッドアイテムごとに、これを処理するための非常に簡単な解決策を見つけました。現在取り組んでいるプロジェクトのスニペットを挿入しました。コントロールの xaml 部分に注目してください: PanoramaItem.HeaderTemplate. ここで、ヘッダー項目のテンプレートを変更します。幸運を!

<!--Panorama item one-->
        <controls:PanoramaItem Header="Locations">   
            <Grid>
                <ListBox Height="498" HorizontalAlignment="Left" Margin="2,0,0,0" Name="listBox1" VerticalAlignment="Top" Width="424" />
            </Grid>

            <controls:PanoramaItem.HeaderTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" FontSize="55" FontFamily="Segoe WP Bold" Foreground="Black" TextAlignment="Left" FontWeight="Normal" FontStyle="Italic" />
                </DataTemplate>
            </controls:PanoramaItem.HeaderTemplate>


        </controls:PanoramaItem>
于 2012-04-30T14:16:05.340 に答える
2

たぶんあなたはこれを下に入れてみることができます<controls:Panorama>

<controls:Panorama.TitleTemplate>
  <DataTemplate>
     <TextBlock Text="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" FontSize="150" Margin="0,20,0,0" FontWeight="Bold" />
  </DataTemplate>
</controls:Panorama.TitleTemplate>

ここにあります:http ://www.jstawski.com/archive/2010/10/25/change-windows-phone-7-panoramarsquos-control-title.aspx

于 2012-01-17T20:33:49.437 に答える
1

独自の PanoramaItem コントロールを作成し、generic.xaml を使用してカスタム PanoramaItem スタイルを適用できます。

public class MyPanoramaItem : Microsoft.Phone.Controls.PanoramaItem

    {
        public MyPanoramaItem()
        {
            DefaultStyleKey = typeof(MyPanoramaItem); 
        }
    }

次に、Themes\Generic.xaml を作成します。

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:YourProjectNamespace"> 

    <Style TargetType="local:MyPanoramaItem">
        <!—your custom PanoramaItem style-->    
    </Style> 
</ResourceDictionary>

そして、カスタム パノラマを次のように使用します。

xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
xmlns:local="clr-namespace:YourProjectNamespace"

<Grid x:Name="LayoutRoot" Background="Transparent"> 
        <!--Panorama control-->
        <controls:Panorama Title="my application">
            <controls:Panorama.Background>
                <ImageBrush ImageSource="PanoramaBackground.png"/>
            </controls:Panorama.Background>

            <!--Panorama item one-->
            <local:MyPanoramaItem Header="first item">
            </ local:MyPanoramaItem >
        </controls:Panorama>

generic.xaml とその使用方法の詳細については、こちらを参照してください

于 2011-05-16T15:14:24.803 に答える