Tip:Changing background of AutoCompleteBox

If we want to change the Background of the AutoCompleteBox, we have to make a small change to the template.  Grab the Style for the AutoCompleteBox from the toolkit source and make the following change and set the style of the control to the name give to our style

 <TextBox IsTabStop=”True”
 x:Name=”Text”         Style=”{TemplateBinding TextBoxStyle}”
        Margin=”0″ />

to

 <TextBox IsTabStop=”True”
 x:Name=”Text” Background=”{TemplateBinding Background }”
        Style=”{TemplateBinding TextBoxStyle}”
        Margin=”0″ />

Actually this might be better solution

<controls:AutoCompleteBox ... >
<controls:AutoCompleteBox.TextBoxStyle>
<Style TargetType="TextBox">
<Setter Property="Background" Value="Red" />
</Style>
</controls:AutoCompleteBox.TextBoxStyle>
</controls:AutoCompleteBox>
Advertisements

One thought on “Tip:Changing background of AutoCompleteBox

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s