ComboBox with GridView? (oh, and a rant :)

1 Answer 70 Views
ComboBox GridView MultiColumnComboBox
Bradley
Top achievements
Rank 2
Iron
Iron
Iron
Bradley asked on 22 Nov 2024, 06:27 PM

I've been working with the Telerik WPF controls for the last couple of months and appreciating them.

<rant>

However, I have a major gripe as well:  most of the examples are FAR too complex.  Here's a perfect example.  I'm trying to get a ComboBox to work with a GridView.  There is an example that does pretty much exactly what I want at https://github.com/telerik/xaml-sdk/tree/master/ComboBox/DropDownWithHeaders.  However,

  1. A simple clone from the repository won't run.  That seems fundamental to me.  When I look into it, the problem is themes.  A simple example should not even include themes!  I would suggest a proper example would allow me to clone and run, with nothing else on my machine but Visual Studio.
  2. When I look into the actual example, it is anything but simple!  The control template is 155 lines of code!?!?!  How do I sort through that quickly and figure out what I need and don't need?  I don't need all kinds of animation or fancy styles.  For the purposes of learning the controls, I need the absolute minimum to make it work!

There is also an example of this at https://www.telerik.com/forums/radcombobox-with-radgridview, but it suffers from the same problems.

This kind of thing seriously makes me ponder going back to our old controls provider.

</rant>

Now, can someone please provide me with a simple example of a ComboBox that uses a GridView for the drop-down?

Of course perhaps I'm using the wrong control.  Maybe I should be using the MultiColumnComboBox, but the end results shown in the examples make it look nothing like a traditional ComboBox.  (Again, that may be owing to a lack of a good, simple example.)

Help?

1 Answer, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 26 Nov 2024, 05:44 PM

Hello Bradley,

Thank you for your feedback and the detailed information.

The following points will share the general workflow when using the Telerik UI for WPF assemblies and when working with the examples from the SDK Samples Browser, as well as for the browser itself.

1. Themes

Generally, the Telerik UI for WPF controls need to be themed. Depending on the chosen version (Xaml or NoXaml), a different theming mechanism is required:

2. Examples (SDK Samples Browser examples)

The examples from the SDK Samples Browser are developer-oriented ones, which are intended to show more complex scenarios and use cases for our controls, such as the one of the RadComboBox, which you shared (xaml-sdk/ComboBox/DropDownWithHeaders at master · telerik/xaml-sdk).

For the above-mentioned example specifically, the two default ControlTemplates of the RadComboBox (for the non-editable and editable modes) are extracted and modified, in order to display a RadGridView in its drop-down. This functionality cannot be achieved without performing such customization due to how the RadComboBox is intended to work by default (placing items one below another in the drop-down). This means that anything outside of the default use case of the control will require modifications and there isn't a "simple example" other than the one that you are referring to. 

The approach chosen for this example is to use the NoXaml assemblies and the implicit styles theming approach, as this will allow for easier extraction and modification of the default control templates and styles. It requires merging the resource dictionaries for the chosen theme, in order to both introduce the customization and theme the control so that they can be visible at runtime.

3. SDK Samples Browser information

For easier work with the examples, and to test them with a single click, we have the SDK Samples Browser, which has to be set up. More information on it can be found at the following link and it also contains a download link for it:

SDK Samples Browser - Telerik UI for WPF

It requires specifying the path to both the Xaml and NoXaml assemblies on your end, as well as the local copy of the GitHub repository.

The GitHub repository itself is suggested when the source code of some of the examples needs to be viewed. For example, navigating to the DropDownWithHeaders example of the RadComboBox control will allow you to review its implementation, copy it, as well as test it, and introduce it in your application if the customization meets the desired requirement and behavior.

Addressing the question about the RadComboBox control with a RadGridView

Generally, for such a requirement we suggest using the RadMultiColumnComboBox control, as it is an out-of-the-box control that has a RadGridView in its drop-down part and a selection box that supports both single and multiple selections.

The RadMultiColumnComboBox control does not look like a traditional combobox control as its use case is to display more than one property in its drop-down. Both the native WPF ComboBox and our RadComboBox are designed to display a single property in the drop-down part (this can be customized as it is shown in the mentioned SDK example with the extracted and modified ControlTemplates). 

Attached files

As per your requirement, I attached a zip file that contains an example that does not contain any customizations such as the RadComboBox one. It contains a RadMultiColumnComboBox from its Getting Started article, which uses the Xaml version of our assemblies (the default theme is Office_Black as the StyleManager is not explicitly utilized). It contains this control, as it is an out-of-the-box one and it also has functionality for customizing it via the provided API, without the need to extract and customize the default styles and templates. 

To run it, add this version of the following assemblies:

  • Telerik.Windows.Controls
  • Telerik.Windows.Controls.GridView
  • Telerik.Windows.Controls.Input
  • Telerik.Windows.Data

With this being said, I hope the provided information will be of help to you. Please let me know if any additional assistance regarding this requirement is needed, as I will be more than happy to assist you further.

Regards,
Stenly
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
ComboBox GridView MultiColumnComboBox
Asked by
Bradley
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Stenly
Telerik team
Share this question
or