Spurious DropDownClosed events in RadDropDownButton

5 posts, 2 answers
  1. KO
    KO avatar
    16 posts
    Member since:
    Apr 2010

    Posted 13 May 2011 Link to this post

    I'm using some RadDatePickers in a RadRadioButton in a RadDropDownButton like so:

                <telerik:RadDropDownButton x:Name="Period" Width="200" DropDownWidth="250" 
    Content="Period: 12/12/2012 to 12/12/2013" DropDownClosed="Period_DropDownClosed" KeepOpen="False">
                    <telerik:RadDropDownButton.DropDownContent>
                        <StackPanel x:Name="Periods" Orientation="Vertical">
                            <telerik:RadRadioButton Content="Today" Tag="0"/>
    .
    .
    .
                            <telerik:RadRadioButton Tag="11">
                                <telerik:RadRadioButton.Content>
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="From" Margin="0,6,6,0" />
                                        <telerik:RadDatePicker x:Name="PrevFromPicker" Height="22" FontSize="9" />
                                        <TextBlock Text="to" Margin="6" />
                                        <telerik:RadDatePicker x:Name="PrevToPicker" Height="22" FontSize="9"/>
                                    </StackPanel>
                                </telerik:RadRadioButton.Content>
                            </telerik:RadRadioButton>
                        </StackPanel>
                    </telerik:RadDropDownButton.DropDownContent>                
                </telerik:RadDropDownButton>

    1) When I make a selection in either of the DatePickers, the DropDownButton's DropDownClosing event fires. The DropDownButton does not close, however; the event just fires without closing. I've tried KeepOpen=true and false, no difference. I could ignore these events and continue editing since the DropDown remains open. However, this handler results in a round trip to the server (using invalid dates) for a great deal of data each time the Closed event fires. The false events are indistinguishable from the real DropDownClosing event. Ideally, I'd like to know how to make these false events go away. The sample project provided in this thread exhibits this same behavior.

    2) I validate the dates in the DropDownClosing event. If they are invalid, I keep the button open by setting the IsOpen property via the Dispatcher, as shown in another similar thread. Is this still the appropriate way to do this? Other threads mention a cancellable DropDownClosing event. The PITS system (ID 3526) says this event was added September, 2010. I'm using 2011.1.419.1040 and don't see any variation of a Closing event.

    3) Is the KeepOpen property documented somewhere?

    4) If I click on any radio button in the DropDownButton directly, that button is selected as expected. If I click either of the DatePickers, then try to select the RadioButton that contains them, it takes two clicks to select the radio button. Any way to reduce this to a one-click operation?

    Thank you,

    KO
  2. KO
    KO avatar
    16 posts
    Member since:
    Apr 2010

    Posted 16 May 2011 Link to this post

    Please ignore #1 in my original post. Marking the DatePicker's DropDownClosed events as handled fixes the behavior. As in:

    private void Picker_DropDownClosed(object sender, RoutedEventArgs e)
    {
        ((RadRoutedEventArgs)e).Handled = true;
    }

    Thanks!
  3. DevCraft banner
  4. Answer
    Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 18 May 2011 Link to this post

    Hello KO,

    2) Yes, currently the combination of Dispatcher and IsOpen is the only way to achieve the desired scenario. We did not manage to implement a Closing event due to some core issues with the Popup. We plan to work on the Closing event during Q2 2011. Thank you for pointing that the PITS issue had been closed without actually providing a Closing event and I apologize for that. I've reopened the PITS issue under a different name "Buttons: Add Closing event to DropDownButton".

    3) Currently there is no documentation regarding the KeppOpen property. It is in our plant to improve the documentation of RadButtons since it has not been updated for a while.

    4) This scenario currently cannot be achieved in Silverlight, only in WPF.

    Thank you for the valuable feedback. I've updated your Telerik points accordingly.

    Regards,
    Kiril Stanoev
    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
  5. KO
    KO avatar
    16 posts
    Member since:
    Apr 2010

    Posted 23 May 2011 Link to this post

    Sorry to revisit this issue, but please see my question #1 above about the DatePicker causing an enclosing RadDropDownButton's events to fire. I found a solution to get rid of the DatePicker's DropDownClosing events. But now I have added a DropDownOpening handler to the RadDropDownButton, and it, too, fires when the DatePicker dropdown is opened. The DatePicker doesn't even have a public DropDownOpening event. I'm very confused as to why the DropDownButton's events are firing, and how to get rid of these events. There is no way I can see to distinguish which control is really opening in the handler, so my DropDownOpening logic (which is very expensive) keeps firing over and over. Is it just not a good idea to use a DatePicker inside a DropDownButton?

    Thanks again,

    KO
  6. Answer
    Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 26 May 2011 Link to this post

    Hi KO,

    You can find the original source of the DropDownOpened event through the RadRoutedEventArgs. In order to use them you will need to cast the RoutedEventArgs of the DropDownOpened() event to RadRoutedEventArgs:
    private void Period_DropDownOpened(object sender, RoutedEventArgs e)
    {
        RadRoutedEventArgs args = e as RadRoutedEventArgs;
        if (args.OriginalSource != sender)
            return;
    }

    The events issues with the RadDatePicker control inside the DropDownContent of the RadDropDownButton are caused by the fact that the RadDatePicker ControlTemplate contains a RadDropDownButton element. Then when the DatePicker dropdown is opened its RadDropDownButton element's events are fired accordingly. And since they aren't handled, they are propagated up in the visual tree to your DropDownButton. And this is why the events you attach to the Period DropDownButton are fired when the DatePicker dropdown is opened/closed.

    I hope this info will help you.

    Kind regards,
    Tina Stancheva
    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
Back to Top
DevCraft banner