开发者

Windows phone 7.1, Listpicker fullmodeitemtemplate binding text

i'm trying to change the font size for my items in a listpicker. I use a fullmodeitemtemplate to be ab开发者_Python百科le to change fontsize etc.

The problem is that i have no idea how to bind the text for the items in the template

<DataTemplate x:Name="PickerFullModeItemTemplate">
            <StackPanel Orientation="Horizontal" Margin="16 21 0 20" Background="Orange" Width="110" Height="110" HorizontalAlignment="Center" VerticalAlignment="Center">
                <TextBlock Text="{WHAT TO TYPE HERE?}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5" FontSize="36"/>
            </StackPanel>
        </DataTemplate>

I populate my listpicker by setting the itemsource in C# like this

foreach (Item i in weight)
            {
                sourceInput.Add(i.name);
            }
        }
        InputSelector.ItemsSource = sourceInput;

This leaves me with an itemsource list only containing strings, then i dont know how to bind the text for each item. I read some post on how to do it when the itemsource list is in this format

source.Add(new Cities() { Name = "Mexico", Country = "MX", Language = "Spanish" });

        this.listPicker.ItemsSource = source;

and then the xaml part is something like this

<TextBlock Text="{Binding Name}"/>

any help would be greatly appreciated :)

UPDATE

i found the correct binding for binding to the sourceitems.

<TextBlock Text="{Binding BindsDirectlyToSource=True}"/>

Looks like thats the way to go, then the source items get binded to the textblock


You should be adding objects of type Cities to your sourceInput collection.

Typing Text="{Binding Name}" is correct.

Most likely your Cities class just doesn't implement the INotifyPropertyChanged interface. You should notify the UI each time you update the Name and other properties you have bound your UI elements to.


<TextBlock Text="{Binding Name}"/>

it is cool but for the listpicker there is also DisplayMemberPath property so,

on listpicker add :

DisplayMemberPath="Name"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜