Closed JeanPhilippeLux closed 1 month ago
@JeanPhilippeLux After some testing I noticed the click event of the inner button is bubbling up to the left button of the SplitButton
(called PART_LeftButton
).
Since I'm somewhat new to this library I'm not sure how to fix it in the control itself, but a quick-fix on your side would be to mark the event as handled in your code behind like this:
private void ExportCardExcel(object sender, RoutedEventArgs e)
{
//do excel stuff here
e.Handled = true;
}
P.S.: Your code does not compile, PackIconKing
is not a property on a Button
. Consider putting a stackpanel containing an icon and text inside of the button if that is want you want.
Hi, Thank you for your reply. Yes my button is not the standard button, it's a homemade User control of type StdOpeButton and he has a PackIconKing property.
For the moment I do thak to fix : I check the type of source and if it's not a StdOpeButton, that means I Click on the submenu element of type StdOpeButton and not on the main button.
private async void BtExportCard_Click(object sender, RoutedEventArgs e) { if (e.OriginalSource is not StdOpeButton) { await viewModel.ExportCard(false); } }
the click in the submenu still like that :
private async void ExportCardExcel(object sender, RoutedEventArgs e) { await viewModel.ExportCard(true); }
Good analysis @corvinsz
I suspect a similar fix to the one you propose would be the right solution here. In the OnApplyTemplate of SplitButton register for the click event from the popup box, simply mark the event as handled. This should probably follow the same null checking and event registration that is being done for the _rightButton
already.
created a pull request 3643 that should fix this issue
Bug explanation
Hi,
I use the splitbutton. If I add a button in the popupcontent, when I click on it, the click event of the button of the popupcontent is fired, but also the Click event of the splitbutton.
here is my code :
If I click on the button of the popupcontent, the "ExportCardExcel" will be fired and afhter the "BtExportCard_Click".
can someone help me?
thank you. Jean-Philippe.
Version
5.1