Question

How to use longlistselector inside a popup control?

If not possible, then any other way to show longlistselector/listbox as a popup ?

Was it helpful?

Solution 2

You can create a new Page and simply put your LongListSelector in it.

For example (Page is called MyPopupPage):

    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <con:LongListSelector x:Name="LongListSelector">
            <con:LongListSelector.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Name}"/>
                </DataTemplate>
            </con:LongListSelector.ItemTemplate>
        </con:LongListSelector>
    </Grid>

Then fill it with whatever you want (Refer to: http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj244365(v=vs.105).aspx)

In your MainPage (the page which should open the popup): Create an object of type Popup like:

Popup LLSPopup = new Popup();

And create a Method to set the MyPopupPage as the overlay of the popup:

private void ShowPopup()
{
    MyPopupPage ovr = new MyPopupPage();
    this.LLSPopup.Child = ovr;
    this.LLSPopup.IsOpen = true;
}

OTHER TIPS

As a popup you can you CustomMessageBox. Instances of CustomMessageBox have property Content, that has no differences from the Content property of any other content controls. So you can put there LongListSelector or ListBox or whatever you want (even Pivot and Panorama), than call Show method. CustomMessageBox will close if user'll click one of the 2 default buttons, but you can hide them (properties IsLeftButtonEnabled and IsRightButtonEnabled) and close CustomMessageBox by your own logic by calling Dismiss method. There is a couple of useful events: the most useful is Dismissed, that raises right after CustomMessageBox get closed (dismissed), its handler contains DismissedEventArgs, that has result of users choiсe (right or left button was chosen, if they were on the screen) and of course sender (CustomMessageBox). If you want some logic after CustomMessageBox closing, use Dismissed event, Show method won't stop program flow.

This is the easiest way to show something. It's not a popup, but it behaves like it.

But if you wont to use popup ifself, there is Child property for you, put there Grid, and ListBox inside the Grid. But you have to set the values of the Width and Height of popup Child.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top