how to close RadDropDownButton programmatically

14 posts, 1 answers
  1. uku
    uku avatar
    57 posts
    Member since:
    Mar 2009

    Posted 19 Nov 2009 Link to this post

    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 
  2. uku
    uku avatar
    57 posts
    Member since:
    Mar 2009

    Posted 20 Nov 2009 Link to this post

    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
  3. DevCraft banner
  4. Answer
    Ivan
    Admin
    Ivan avatar
    519 posts

    Posted 20 Nov 2009 Link to this post

    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.
  5. Nathan
    Nathan avatar
    24 posts
    Member since:
    Sep 2009

    Posted 03 Feb 2010 Link to this post

    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
  6. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 04 Feb 2010 Link to this post

    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.
  7. Nathan
    Nathan avatar
    24 posts
    Member since:
    Sep 2009

    Posted 05 Feb 2010 Link to this post

    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.
  8. Michael
    Michael avatar
    15 posts
    Member since:
    Dec 2009

    Posted 19 Mar 2010 Link to this post

    IsOpen = true; seems to work as well.
  9. Ivan
    Admin
    Ivan avatar
    519 posts

    Posted 22 Mar 2010 Link to this post

    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.
  10. Mariya Angelova
    Mariya Angelova avatar
    1 posts
    Member since:
    Jun 2012

    Posted 14 Jul 2010 Link to this post

    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
  11. Vladislav
    Admin
    Vladislav avatar
    275 posts

    Posted 19 Jul 2010 Link to this post

    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
  12. Chen
    Chen avatar
    18 posts
    Member since:
    Apr 2012

    Posted 11 May 2012 Link to this post

    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
  13. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 16 May 2012 Link to this post

    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 >>

  14. Matthew Goodman
    Matthew Goodman avatar
    1 posts
    Member since:
    Jul 2012

    Posted 17 Jul 2012 Link to this post

    Nevermind
  15. Ryan
    Ryan avatar
    7 posts
    Member since:
    Jun 2012

    Posted 18 Jul 2012 Link to this post

    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
Back to Top
DevCraft banner