This is a migrated thread and some comments may be shown as answers.

[Solved] How to create a style for the Header of a RadAutoComplete?

1 Answer 104 Views
AutoCompleteBox for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
YYZRichard
Top achievements
Rank 2
YYZRichard asked on 08 Jun 2013, 06:19 AM
I created a style for the Header of the RadAutoComplete control, but I'm not able to assign the style to the header.
<ResourceDictionary
    xmlns:Input="using:Telerik.UI.Xaml.Controls.Input"
 
    <Style x:Key="TestStyle" TargetType="TextBlock">
        <Setter Property="FontFamily" Value="Segoe UI Symbol"/>
        <Setter Property="Foreground" Value="#FF008A00"/>
        <Setter Property="FontSize" Value="30" />
        <Setter Property="TextWrapping" Value="Wrap" />
    </Style>
         
</ResourceDictionary>

Here's how I'm referring to the style in the XAML file:
<Input:RadAutoCompleteBox Header="Test" HeaderStyle="{StaticResource TestStyle}" />

I'm getting the following error message:
Failed to assign to property "Windows.UI.Xaml.FrameworkElement.Style".

I'm assuming the header element is a TextBlock, so the style TargetType="TextBlock". If that is not the case, could you please provide an example on how to define a style for the header?

Thank you.







1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 10 Jun 2013, 12:29 PM
Hi Richard,

Thank you for contacting us.

The RadAutoCompleteBox header is implemented as a ContentControl. That is why you have to set the TargetType property to ContentControl when applying a custom style.
However, if you want to control the text wrapping (as shown in your code snippet), you will need to define a HeaderTemplate with a TextBlock insteadHere is a link to our documentation that describes how to define a custom style or a custom template for the Header.


Regards,
Alexander
Telerik
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Tags
AutoCompleteBox for XAML
Asked by
YYZRichard
Top achievements
Rank 2
Answers by
Alexander
Telerik team
Share this question
or