次の方法で共有


AutoCompleteBox.TextBoxStyle Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the Style applied to the text box portion of the AutoCompleteBox control.

Namespace:  System.Windows.Controls
Assembly:  System.Windows.Controls.Input (in System.Windows.Controls.Input.dll)

Syntax

'Declaration
Public Property TextBoxStyle As Style
public Style TextBoxStyle { get; set; }
<sdk:AutoCompleteBox TextBoxStyle="staticResourceReference"/>

XAML Values

  • staticResourceReference
    A reference to an existing Style resource in a resource dictionary.

Property Value

Type: System.Windows.Style
The Style applied to the text box portion of the AutoCompleteBox control. The default is nulla null reference (Nothing in Visual Basic).

Examples

The following example shows how to set a custom style for the TextBoxStyle and the ItemContainerStyle properties. This code example requires a reference to the System.Windows.Controls.Input assembly.

Run this sample

myACB.ItemsSource = New String() {"London", "Paris", _
    "Johannesburg", "Bucharest", "Berlin", "Lisbon", "New York", _
    "Nairobi", "Seattle", "Mexico City", "Vancouver"}
myACB.ItemsSource = new String[]{"London", "Paris", 
    "Johannesburg", "Bucharest", "Berlin", "Lisbon","New York", 
    "Nairobi", "Seattle", "Mexico City", "Vancouver"};
<Border BorderBrush="DarkGray" BorderThickness="2">
    <StackPanel x:Name="LayoutRoot" Background="LightYellow" Orientation="Vertical">
        <TextBlock Margin="5" Text="TextBoxStyle and ItemContainerStyle Example" />
        <StackPanel Orientation="Horizontal">
             <StackPanel.Resources>
                    <Style  x:Key="myTBStyle" TargetType="TextBox">
                    <Setter Property="Background" Value="LightYellow" />
                    <Setter Property="Foreground" Value="DarkSlateGray" />
                    <Setter Property="Margin" Value="5" />
                    <Setter Property="FontWeight" Value="Bold" />
                    <Setter Property="FontSize" Value="14" />
                    <Setter Property="BorderBrush" Value="DarkGray" />
                </Style>
                <Style  x:Key="myLBStyle" TargetType="ListBoxItem">
                    <Setter Property="Background" Value="Khaki" />
                    <Setter Property="Foreground" Value="DarkSlateGray" />
                    <Setter Property="Margin" Value="5" />
                    <Setter Property="FontStyle" Value="Italic" />
                    <Setter Property="FontSize" Value="14" />
                    <Setter Property="BorderBrush" Value="DarkGray" />
                </Style>
            </StackPanel.Resources>
            <TextBox Height="30" Width="Auto" IsReadOnly="True" Text="Enter city:" 
                Style="{StaticResource myTBStyle}" BorderBrush="LightGray" />
            <sdk:AutoCompleteBox Width="150"  Height="30" x:Name="myACB" 
                TextBoxStyle="{StaticResource myTBStyle}" 
                ItemContainerStyle="{StaticResource myLBStyle}" />
        </StackPanel>
    </StackPanel>
</Border>

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.