Height and Margin settings for RadWatermarkTextBox affecting RadMultiColumnComboBox in WPF view

1 Answer 29 Views
MultiColumnComboBox WatermarkTextBox
Daniel
Top achievements
Rank 1
Daniel asked on 13 Jul 2021, 02:40 PM

I have a WPF view that contains both watermark text boxes and multicolumn combo boxes. I would like to set their properties in the resources of the view. I am having an issue where the settings of the watermarktextbox are affecting the appearance of the multicolumncombobox. Below is my code for the settings (This is under the resources of the view)


        <Style TargetType="{x:Type telerik:RadWatermarkTextBox}">
            <Setter Property="Padding" Value="3" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="telerik:StyleManager.Theme" Value="Office2019" />
            <Setter Property="Height" Value="25" />
            <Setter Property="Margin" Value="5 5 5 0" />
        </Style>

        <Style TargetType="{x:Type telerik:RadMultiColumnComboBox}">
            <Setter Property="Height" Value="25" />
            <Setter Property="Margin" Value="5,5,5,0"/>
            <Setter Property="telerik:StyleManager.Theme" Value="Office2019" />
        </Style>

Below is a screenshot of the of the view - notice the drop down icon of the combobox is off it has the downarrow on the right but then also up and down arrows to the left of the drop down arrow - i think its a scroll bar

 

I can fix this in a couple ways but neither are ideal:
 1) I can set the height of the multi column combobox to 31 to get rid of those scroll bars. However, I would like all of my controls to be 25

2) I can remove the Height and Margin setters from the watermarktextbox but then I would have to go through and add those properties to each individual watermark textbox in my view

 

is there a setter property I can add to either the resources that would cancel out the values from the watermarktextbox or is there a way to cancel them out via a setting on each individual multicolumncombobox??

 

Thank you!

1 Answer, 1 is accepted

Sort by
0
Dinko
Telerik team
answered on 16 Jul 2021, 07:57 AM

Hello Daniel,

The same questions were asked in a support ticket. I am sharing my reply also here.

The custom style targeting RadWatermarkTextBox is an implicit one. I understand that you want to target all RadWatermarkTextBox controls in the app and apply the same style to it. However, in your case RadMultiColumnComboBox contains inside a RadWatermarkTextBox. What you can do here is to set x: Key to the style targeting RadWatermarkTextBox control. Then you can set the Style property of each RadWatermarkTextBox in your application to point to this style.

Another approach will be to directly set the Style property of the RadWatermarkTextBox inside the RadMultiColumnComboBox to empty style, which will have a higher priority from the implicit style. You can get the RadWatermarkTextBox inside the Loaded event of RadMultiColumnComboBox.

private void Mccb_Loaded(object sender, RoutedEventArgs e)
{
    RadWatermarkTextBox inputWatermarkTextBox = this.mccb.ChildrenOfType<RadWatermarkTextBox>().FirstOrDefault(x => x.Name == "WatermarkTextBox");
    if(inputWatermarkTextBox != null)
    {
        inputWatermarkTextBox.Style = new Style();
    }
}

Regards,
Dinko
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly, just got a fresh new look + new and improved content, including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
MultiColumnComboBox WatermarkTextBox
Asked by
Daniel
Top achievements
Rank 1
Answers by
Dinko
Telerik team
Share this question
or