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

Spurious DropDownClosed events in RadDropDownButton

4 Answers 104 Views
Buttons
This is a migrated thread and some comments may be shown as answers.
KO
Top achievements
Rank 1
KO asked on 13 May 2011, 06:40 PM
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

4 Answers, 1 is accepted

Sort by
0
KO
Top achievements
Rank 1
answered on 16 May 2011, 04:01 PM
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!
0
Accepted
Kiril Stanoev
Telerik team
answered on 18 May 2011, 02:17 PM
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
0
KO
Top achievements
Rank 1
answered on 24 May 2011, 01:37 AM
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
0
Accepted
Tina Stancheva
Telerik team
answered on 26 May 2011, 03:20 PM
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
Tags
Buttons
Asked by
KO
Top achievements
Rank 1
Answers by
KO
Top achievements
Rank 1
Kiril Stanoev
Telerik team
Tina Stancheva
Telerik team
Share this question
or