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

how to close RadDropDownButton programmatically

13 Answers 1006 Views
Buttons
This is a migrated thread and some comments may be shown as answers.
uku
Top achievements
Rank 1
uku asked on 19 Nov 2009, 10:13 PM
Hello,

I'm using the new RadDropDownButton and placed a list box inside. After an item is selected by the user I want to close the DropDownContent programmatically without any additional user action.

Does anyone know how to do this?

Thanks for your help

Uwe 

13 Answers, 1 is accepted

Sort by
0
uku
Top achievements
Rank 1
answered on 20 Nov 2009, 08:56 PM
Forget my question about closing the RadDropDownButton. I've overlooked that there is an IsOpen property which can not only be used for checking if the drop down button is open, but can also set to false and then the button closes.

Bye

Uwe
0
Accepted
Ivan
Telerik team
answered on 20 Nov 2009, 10:08 PM
Hi Uwe,

Thank you for your interest in the RadButtons.

Actually you find the right way. The only thing you should do is to set the button's IsOpen property to False at the right moment.

If you have any other questions about RadButtons please do not hesitate to contact us.

Kind regards,
Ivan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Nathan
Top achievements
Rank 2
answered on 03 Feb 2010, 06:58 PM
Hello,

Is there any way to set the drop down button to close automatically when an item is selected? My drop down button is in a data template, so I don't have easy access to the object be able to set "IsOpen" in this manner. I tried walking up the visual tree to the parent, but of course there are grids, stackpanels, and who knows what else in between so the code gets ugly fast.

Any thoughts would be appreciated!
Nate
0
Valentin.Stoychev
Telerik team
answered on 04 Feb 2010, 01:04 PM
Hello Nathan Riske,

you can use a class handler to handle the event you need on the RadDropDownButton. Please read more on the class handlers here:
http://wildermuth.com/2010/01/28/Handing_Events_with_Care

Regards,
Valentin.Stoychev
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Nathan
Top achievements
Rank 2
answered on 05 Feb 2010, 08:28 PM

Thanks for the idea. This didn't work out well in my scenario, since to add the handler in this manner I also need access to the object. Having said that I learned a lot about bubbling of handled events in the post! 

In the end (for anyone else trying to do this), I did the following:

In the mouseenter event, I grab a reference to the raddropdownbutton:

        If mSeriesDrop Is Nothing Then  
            mSeriesDrop = TryCast(sender, RadDropDownButton)  
        End If 

 

Then in my menu click events, I add the following:

        If mSeriesDrop IsNot Nothing Then  
            mSeriesDrop.IsOpen = False 
        End If 
Certainly not an elegant solution, but it does the trick. I suppose since utilizing the mouseenter event I now DO have a reference to the object I could use the method indicated in the blog from that point on to add the handler and get the bubbled mousedown event - at least then it would save me the effort of "closing" the main drop button on any item click.
0
Michael
Top achievements
Rank 1
answered on 19 Mar 2010, 10:21 PM
IsOpen = true; seems to work as well.
0
Ivan
Telerik team
answered on 22 Mar 2010, 11:33 AM
Hi Michael,

Yes, the IsOpen property get and set the state of the drop-down button. Manipulating its value is the right way to deal with the button drop-down-state.

Regards,
Ivan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Mariya Angelova
Top achievements
Rank 1
answered on 14 Jul 2010, 12:31 PM
Hi
In my case IsOpen didn't work always. Sometimes the RadDropDownButton is open but the value of IsOpen = false so I can close it anyway.
Have you any idea why the IsOpen - property is not valuated correctly?

Thanks, Mariya
0
Vladislav
Telerik team
answered on 19 Jul 2010, 12:56 PM
Hello Mariya Angelova,

We are not aware of such problem with RadDropDownButton, nor we wasn't able to reproduce the described issue.
Can we ask you to provide us with a sample project demonstrating the problem?
How are you checking the value of the "IsOpen" property while the RadDropDownButton is open?

Greetings,
Vladislav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Chen
Top achievements
Rank 1
answered on 11 May 2012, 02:58 PM
Hi Ivan,

I have a RADDropdownButton and am working on MVVM pattern. In this pattern, I do not have the access to the control in the view. How can I close the dropdown list by setting its IsOpen property to false after clicking it ?

By the way, it seems to me that the click event fires twice when I click on the list. Are you aware of it by any chance?

Thanks in advance.

Chen
0
Petar Mladenov
Telerik team
answered on 16 May 2012, 08:25 AM
Hi Chen,

 Clicking on a RadDropDown fires only once the Click event. You can check this out in the attached project. On the other hand, currently we have an issue when the button's IsOpen is set to True initially the button is not open. Is this related to your question ? We will do our best to have this fixed for the upcoming Q2.

Kind regards,
Petar Mladenov
the Telerik team

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

0
Matthew Goodman
Top achievements
Rank 1
answered on 17 Jul 2012, 10:52 PM
Nevermind
0
Ryan
Top achievements
Rank 1
answered on 18 Jul 2012, 02:15 PM
Once i was stuck in this kind of button making event but i am happy to get it right, and this forum is truly helping me in knowing the Silver Light plug-in. The coding i was stuck in and then got it correct was:

<UserControl x:Class="ButtonControls.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="200" Height="100">
    <Canvas x:Name="cnvLayoutRoot" Background="White">
        <TextBlock x:Name="tblText" Canvas.Top="20" Canvas.Left="30" Text="Not clicked yet."></TextBlock>
        <Button x:Name="btnTest" Canvas.Top="60" Canvas.Left="30"Click="btnTest_Click" Content="Click me!"></Button>
    </Canvas>
</UserControl>

May this will help someone like me.

silverlight development | silver light application
Tags
Buttons
Asked by
uku
Top achievements
Rank 1
Answers by
uku
Top achievements
Rank 1
Ivan
Telerik team
Nathan
Top achievements
Rank 2
Valentin.Stoychev
Telerik team
Michael
Top achievements
Rank 1
Mariya Angelova
Top achievements
Rank 1
Vladislav
Telerik team
Chen
Top achievements
Rank 1
Petar Mladenov
Telerik team
Matthew Goodman
Top achievements
Rank 1
Ryan
Top achievements
Rank 1
Share this question
or