I have edited the question to include more info based on the feedback.
In my SettingsPage.xaml I have
<toolkit:ListPicker x:Name="lpkCountry"
ItemTemplate="{Binding Source={StaticResource lpkItemTemplate}}"
FullModeItemTemplate="{Binding Source={StaticResource lpkFullItemTemplate}}"
Header="your country" CacheMode="BitmapCache"
HorizontalAlignment="Left" VerticalAlignment="Top" Width="280" Height="82" />
I am trying to bind the ListPicker DataTemplate to the following XAML placed in the App.xaml page
<Application.Resources>
<DataTemplate x:Name="lpkItemTemplate">
<TextBlock Text="{Binding Country}" />
</DataTemplate>
<DataTemplate x:Name="lpkFullItemTemplate">
<TextBlock Margin="16 0 0 0" Text="{Binding Country}" />
</DataTemplate>
</Application.Resources>
The SettingsPage.xaml.cs defined Country as public static string array:
namespace myspace
{
public partial class SettingsPage : PhoneApplicationPage
{
public static String[] Country = {
"Afghanistan",
"Åland Islands",
"Albania",
"Algeria",
"American Samoa",
"Andorra",
"Angola"}
......;
Also on the SettingsPage.xaml.cs I have defined the datacontext to another object.
public SettingsPage()
{
InitializeComponent();
this.lpkCountry.SelectionChanged += new SelectionChangedEventHandler(lpkCountry_SelectionChanged);
this.lpkCountry.ItemsSource = Country;
settings = new AppSettings();
this.DataContext = settings;
}
But on runtime when I go to SettingsPage I get many errors of this kind
System.Windows.Data Error: BindingExpression path error: 'Country' property not found on 'Afghanistan' 'System.String' (HashCode=-2039466552). BindingExpression: Path='Country' DataItem='Afghanistan' (HashCode=-2039466552); target element is 'System.Windows.Controls.TextBlock' (Name=''); target property is 'Text' (type 'System.String')..
I understand that there's conflict between target element and target property, so how to fix this?