0

Quite new to Windows Phone Applications.

Trying to create something similar to a Drop Down List, found the ListPicker. After doing some more research once it didn't work, I have come to the following code:

<toolkit:ListPicker x:Name="listActions" Grid.Row="1" Width="340" HorizontalAlignment="Left" VerticalAlignment="Center">
            <toolkit:ListPicker.ItemTemplate>
                <DataTemplate>
                    <StackPanel>
                        <TextBlock Text="{Binding Name}" />
                    </StackPanel>
                </DataTemplate>
            </toolkit:ListPicker.ItemTemplate>
            <toolkit:ListPicker.FullModeItemTemplate>
                <DataTemplate>
                    <StackPanel>
                        <TextBlock Text="{Binding Name}" />
                    </StackPanel>
                </DataTemplate>
            </toolkit:ListPicker.FullModeItemTemplate>
        </toolkit:ListPicker>

However, when I try to set the ItemSource I am getting a Null Reference exception, which is coming from the ListPicker object.

listActions.ItemsSource = Storage.Register.ActionDefinitions;

Any ideas on why this is happening or how to fix it would be greatly appreciated.

Thanks in advance

Seige
  • 304
  • 5
  • 27

2 Answers2

0

You haven't shown enough code to confirm it but the only reason this should happen would be if you were trying to set the ItemsSource in the page constructor before InitializeComponent() is called.

Matt Lacey
  • 65,560
  • 11
  • 91
  • 143
  • I am setting the ItemsSource in the PhoneApplicationPage_Loaded() method which, correct me if I am wrong, gets called after. – Seige Sep 20 '13 at 03:01
0

I'm not sure what happened. But I did all the usual things including wiping the code and re-making it identically. so weather something behind the code was missing or something I don't know. But it has started working now.

Thanks for the help, all information, weather useful or not so much is still greatly appreciated.

Seige
  • 304
  • 5
  • 27
  • This may have been caused by the application on the emulator not updating when I try to run it. and having to close the emulator completely for any changes to work – Seige Sep 24 '13 at 02:14