无法更改 ListPicker FullModeItemTemplate 的字体大小 [英] Unable to change FontSize of ListPicker FullModeItemTemplate

查看:22
本文介绍了无法更改 ListPicker FullModeItemTemplate 的字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 ListPicker,当我点击它时,我会看到全屏弹出窗口,但是那里的选项都非常小,无论出于何种原因我都无法更改 FontSize.

I have a ListPicker, and when I click on it I have the full screen popup, but the options there are all pretty small, and I can't change the FontSize for whatever reason.

代码:

<phone:PhoneApplicationPage.Resources>
    <DataTemplate x:Name="PickerFullItemTemplate">
        <StackPanel>
            <TextBlock Text="{Binding Number}"/>
        </StackPanel>
    </DataTemplate>
</phone:PhoneApplicationPage.Resources>


<toolkit:ListPicker ExpansionMode="FullScreenOnly" Name="Picker" ItemsSource="{Binding Number, ElementName=this}" FullModeItemTemplate="{Binding PickerFullItemTemplate}" />

如何为全屏弹出大小 36 字体制作文本?

How do I make the text for the full screen popup size 36 font?

我应该提到,如果我在模板中设置字体大小(如下所示),它不起作用.我可以在列表选择器上设置字体大小,但显然这不会改变完整模式弹出窗口.此外,我已将 ListPicker 从它所包含的 Pivot 中取出并尽可能多地注释掉,因此没有什么可能会覆盖此设置,但仍然没有.

I should mention that if I set the font size in the templates (as suggested below) it doesn't work. I can set the font size on the list picker but obviously that doesn't change the full mode popup. Also, I have taken the ListPicker out of the Pivot it is contained within and commented out as much as possible so there is nothing possibly overriding this setting but still nothing.

推荐答案

执行以下操作:

1) 使用您的值列表创建一个类

1) Create a class with your list of values

public class Number
{
    public IEnumerable<string> number { get { return "AA1,AA2,AA3".Split(','); } }
}

2) 在 xaml 文件的顶部声明你项目的命名空间

2) Declare the namespace of your project in the top of the xaml file

xmlns:local="clr-namespace:YourAppNameSpaceGoesHere"

3) 在 PhoneApplicationPage 资源部分将您的类声明为资源

3) Declare your class as a resource in the PhoneApplicationPage Resources section

4) 在您的 DataTemplate TextBlock 中,只需将 Text 值定义为{Binding}"并设置您的 FontSize

4) In your DataTemplate TextBlock, just define the Text value as "{Binding}" and set your FontSize

<phone:PhoneApplicationPage.Resources>
    <local:Number x:Key="Number"/>
    <DataTemplate x:Name="PickerFullItemTemplate">
        <StackPanel>
            <TextBlock Text="{Binding}" FontSize="36"/>
        </StackPanel>
    </DataTemplate>
</phone:PhoneApplicationPage.Resources>

5) 将您的 ListPicker 控件包装成一个类似于 Grid 的容器控件,并将 Grid 的 DataContext 设置为您的类

5) Wrap your ListPicker control is a container control like a Grid and set the Grid's DataContext to your class

6) ListPicker 中的 FullModeItemTemplate 应定义为 StaticResource

6) The FullModeItemTemplate in your ListPicker should be defined as a StaticResource

    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0" DataContext="{StaticResource Number}">
        <toolkit:ListPicker ExpansionMode="FullScreenOnly" Name="Picker" ItemsSource="{Binding number}" FullModeItemTemplate="{StaticResource PickerFullItemTemplate}" />
    </Grid>

这篇关于无法更改 ListPicker FullModeItemTemplate 的字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆