Pergunta

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

Foi útil?

Solução 2

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.

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top