简体   繁体   中英

XAML - Show message box when combobox item selected

I have a combo box in the ribbon of the window. I wanted to know how can I show message box when each of the item is selected.

<dxr:RibbonPageGroup Caption="Type">
    <dxb:BarEditItem x:Name="BarEditItem2" EditHeight="20" EditWidth="120" >
        <dxb:BarEditItem.EditSettings>
            <dxe:ComboBoxEditSettings PopupMaxWidth="150" PopupMaxHeight="50" Name="comboBox1">
                <dxe:ComboBoxEditSettings.Items >
                    <system:String>Item1</system:String>
                    <system:String>Item2</system:String>
                </dxe:ComboBoxEditSettings.Items>
            </dxe:ComboBoxEditSettings>
        </dxb:BarEditItem.EditSettings>
    </dxb:BarEditItem>
</dxr:RibbonPageGroup>

Can anyone please tell me how to perform this operation?

I think you need to set the control template instead of using the EditSettings, then you can add event handlers for the ComboBox

<dxb:BarEditItem.EditTemplate>
    <DataTemplate>
        <dxe:ComboBoxEdit x:Name="PART_Editor"
                          SelectedIndexChanged="OnSelectedIndexChanged">
            <dxe:ComboBoxEdit.Items>
                <system:String>Item1</system:String>
                <system:String>Item2</system:String>
            </dxe:ComboBoxEdit.Items>
        </dxe:ComboBoxEdit>
    </DataTemplate>
</dxb:BarEditItem.EditTemplate>

Handler

public void OnSelectedIndexChanged(object sender, RoutedEventArgs args)
{
    MessageBox.Show("");
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM