I'm looking for a simple way to increase the DropDown button width in the RadComboBox. I've seen a number of styling solutions that consist of like two or three hundred lines of XAML. Is there an easier way to achieve this?
6 Answers, 1 is accepted
0
Hello,
I believe that you are referring to solutions that require modifications of the ControlTemplate. Generally, this is a standard approach when visually modifying WPF controls. To avoid the complication of a View's structure, you can assign the modified template through a separate Style and separate the Style definition in a separate resource dictionary file. However, you still have a few other options, if you want to avoid this.
You can defined an implicit style that targets RadToggleButton in an appropriate resource scope. For instance, if you want to affect only one instance of RadComboBox that you want to customize, you can set it like this:
Anothe option is to set it at run-time. You can subscribe to the control's Loaded event, find the button on the event's occurrence and set the fixed width.
Regards,
Ivan Ivanov
Telerik by Progress
I believe that you are referring to solutions that require modifications of the ControlTemplate. Generally, this is a standard approach when visually modifying WPF controls. To avoid the complication of a View's structure, you can assign the modified template through a separate Style and separate the Style definition in a separate resource dictionary file. However, you still have a few other options, if you want to avoid this.
You can defined an implicit style that targets RadToggleButton in an appropriate resource scope. For instance, if you want to affect only one instance of RadComboBox that you want to customize, you can set it like this:
<
telerik:RadComboBox
. . .>
<
telerik:RadComboBox.Resources
>
<
Style
TargetType
=
"telerik:RadToggleButton"
>
<
Setter
Property
=
"Width"
Value
=
"300"
/>
</
Style
>
</
telerik:RadComboBox.Resources
>
</
telerik:RadComboBox
>
Regards,
Ivan Ivanov
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Jace
Top achievements
Rank 1
answered on 02 Jan 2017, 03:03 PM
This was a breeze to implement.
Thanks, Ivan. I appreciate it.
0
Jace
Top achievements
Rank 1
answered on 02 Jan 2017, 03:47 PM
Ivan,
I'm able to set the RadToggleButton property through XAML, but struggle to apply it through code via the controls loaded event.
private void rcb_Loaded(object sender, RoutedEventArgs e)
{
var rcb = sender as RadComboBox;
Style style = new Style() { TargetType = typeof(RadToggleButton) };
style.Setters.Add(new Setter() { Property = WidthProperty, Value = 80 });
rcb.Style = style;
}
0
Hello,
It would be easier to set the property value directly instead of using a style. To find the button in the visual tree, you can use Telerik.Windows.Controls.ChildrenOfType<T>, which is a very handy method:
Regards,
Ivan Ivanov
Telerik by Progress
It would be easier to set the property value directly instead of using a style. To find the button in the visual tree, you can use Telerik.Windows.Controls.ChildrenOfType<T>, which is a very handy method:
private void RadComboBox_Loaded(object sender, RoutedEventArgs e)
{
(sender as RadComboBox).ChildrenOfType<
RadToggleButton
>().First().Width = 80;
}
Regards,
Ivan Ivanov
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Jace
Top achievements
Rank 1
answered on 02 Jan 2017, 04:27 PM
For heaven sake. That was too easy.
Thanks, Ivan... I wish you a great 2017!
0
Hi,
You too! I was glad to help.
Regards,
Ivan Ivanov
Telerik by Progress
You too! I was glad to help.
Regards,
Ivan Ivanov
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.