I'm using Toolkit ListPicker in my Windows Phone 8 project and have begun localising it. I've run into a problem because i can't figure out how to do this with a ListPicker.
<toolkit:ListPicker x:Name="lstClubsPick"
FontSize="30"
Grid.Column="1"
VerticalAlignment="Center"
SelectionMode="Single"
HorizontalAlignment="Center"
SelectedIndex="{Binding KolleSelectedIndex, Mode=TwoWay}"
CacheMode="BitmapCache"
ExpansionMode="FullScreenOnly" >
<toolkit:ListPickerItem Content="{Binding Path=LocalizedResources.chooseClub, Source={StaticResource LocalizedStrings}}"/>
<sys:String>Choose</sys:String>
<sys:String>D1</sys:String>
<sys:String>D2</sys:String>
<sys:String>D3</sys:String>
<sys:String>D4</sys:String>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Tap">
<cal:ActionMessage MethodName="ClubClicked">
<cal:Parameter Value="{Binding ElementName=lstPivot,Path=SelectedItem, Mode=TwoWay}"></cal:Parameter>
<cal:Parameter Value="{Binding ElementName=lstClubsPick,Path=SelectedItem, Mode=TwoWay}"></cal:Parameter>
</cal:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
So the problem I'm facing is that i don't know how to get <sys:String>Choose</sys:String>
to look for a string in my AppResources.resx. I've tried this:
<toolkit:ListPickerItem Content="{Binding Path=LocalizedResources.chooseClub, Source={StaticResource LocalizedStrings}}"/>
instead of the <sys:string>
but that makes my app crash. I've searched google and that was the only possible solution i could find. Anyone able to help me? Would be much appreciated.
EDIT 1: So I've updated my code with the solution from andreask but my ListPicker is not responding to the string i add in my viewModel.
private ObservableCollection<string> _data;
public ObservableCollection<string> Data
{
get
{
return _data;
}
set {
_data = value;
NotifyOfPropertyChange(() => Data);
}
}
Data = new ObservableCollection<string>();
Data.Add("Test");
<toolkit:ListPicker x:Name="lstClubsPick" FontSize="30" Grid.Column="1" VerticalAlignment="Center" SelectionMode="Single" HorizontalAlignment="Center" ItemsSource="{Binding Data}" SelectedIndex="{Binding KolleSelectedIndex, Mode=TwoWay}" CacheMode="BitmapCache" ExpansionMode="FullScreenOnly">
Anything I'm doing wrong?
EDIT 2: Thanks a lot for your answers you definitely pointed me in the right direction. I found a solution to my problem i binded my Pivot view's ItemsSource and from that i could in me view model add an ObservableCollection<string>
then i could run this code again from my view model LstItems[PivotSelectedIndex].Data = new ObservableCollection<string>(items);
where items
is an string array. So in my String array i could make a string using the app resource with AppResources.YourResourceName
.