This is a migrated thread and some comments may be shown as answers.

Opening a listpicker programatically

10 Answers 175 Views
ListPicker
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nathan
Top achievements
Rank 2
Nathan asked on 26 Oct 2011, 07:00 AM
I have noticed there is not a way to do this...is there?  Such as, RadListPicker.open()?
I'll explain my purpose and maybe I'm just missing something.
I would like to have a button of some kind, like a + symbol, open a popup listpicker control.  Then based on the item selected, populate a stackpanel of textblocks.
But the listpicker would be unseen otherwise.  Would a different control work better?  Is there a way to open the listpicker programatically?

Thanks for the support!

10 Answers, 1 is accepted

Sort by
0
Accepted
Deyan
Telerik team
answered on 26 Oct 2011, 03:42 PM
Hello Nathan,

You can use the RadListPicker.IsExpanded property for your purpose.

Greetings,
Deyan
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Nathan
Top achievements
Rank 2
answered on 27 Oct 2011, 05:46 AM
Hello Telerik. Had a follow up question: I have noticed that when I subscribe the selectionchanged event to teh RadListPicker (after adding the items) , it fires the event.  After some testing, I realized that I don't have to add anything to it.  Merely the act of subscribing the event fires it.  See below.

Example-
public PageConstructor()
{
InitializeComponent();
test.SelectionChanged += new SelectionChangedEventHandler(test_SelectionChanged);
}
void test_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
throw new NotImplementedException();
}

it will hit the NotImplementedException on page load in debugging. Am I missing something here? I haven't added anything to the RadListPicker. What you see here is the exact code that fires it. There is no databinding or items being added. Nothing was clicked, only page load.

Am I just totally missing something here?
Thanks for the help in the previous question!

UPDATE: as a workaround, I check for the IsExpanded property to see if it's been opened to get the value chosen.  If true, I go ahead and do my logic.
Would still like to know an answer in general on why this event fires on subscription, but this is a good workaround.
0
Georgi
Telerik team
answered on 31 Oct 2011, 09:32 AM
Hi Nathan,

Thanks for getting back to us.

This behavior is by design. The listpicker will always try to select its first item if no user selection is defined. Hence, the SelectionChanged event is raised upon control's loading, when this default selection is performed.

Does this make sense, what is your opinion in this case - should we raise the event, letting the user know that the selection is changed or we should make it silently?


Regards,
Georgi
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Nathan
Top achievements
Rank 2
answered on 01 Nov 2011, 06:09 AM
Well, I suppose I could understand in the case of the databinding.  It does make some sense in certain cases.  But at event subscription time?  I cannot think of a time where this would be a welcome time to fire the event, especially when no data has been bound.  It's your call though and I've certainly found work-arounds for my particular case.
Thanks for asking for my input!  Keep up the good work!
0
Georgi
Telerik team
answered on 02 Nov 2011, 10:03 AM
Hi Nathan,

Thanks for getting back to us and for your input.

The event is not raised at the same moment when you subscribe for it. It is raised upon control's loading phase, which occurs when the page is about to be displayed. So, if you add an event handler in the constructor, you will get the initial SelectionChanged. If you however hook page's Loaded event and add the handler there you will not get the initial SelectionChanged because the control itself is already loaded and has performed its default selection.

I hope this helps. Do not hesitate to contact us with any question/problem you may have with our tools.

All the best,
Georgi
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Nathan
Top achievements
Rank 2
answered on 03 Nov 2011, 09:13 PM
Ah, OK.  I see what you are saying.  Thanks for claryfing the order of events!
0
Laurensius
Top achievements
Rank 1
answered on 06 Mar 2014, 11:24 AM
hi sorry for bringing this post up but can you tell me how to use this RadListPicker.IsExpanded for your situation? because i want to also showing radlistpicker fullscreen popup when i tap my image
0
Deyan
Telerik team
answered on 06 Mar 2014, 12:11 PM
Hi Laurensius,

Doesn't simply setting the IsExpanded to true or false solve your problem?

Regards,
Deyan
Telerik

DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!

0
Laurensius
Top achievements
Rank 1
answered on 06 Mar 2014, 12:14 PM
hmm what i mean is where i should put that in c#? do i need to put listpicker in my xaml? 
0
Deyan
Telerik team
answered on 07 Mar 2014, 08:18 AM
Hello Laurensius,

I am not quite sure that I correctly understand your question.

You need to have a list picker instance on your page with assigned x:Name property to be able to access it in the code-behind file and call its methods or properties.

Regards,
Deyan
Telerik

DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!

Tags
ListPicker
Asked by
Nathan
Top achievements
Rank 2
Answers by
Deyan
Telerik team
Nathan
Top achievements
Rank 2
Georgi
Telerik team
Laurensius
Top achievements
Rank 1
Share this question
or