无法更改Wpf工具包自动完成框的背景?

时间:2012-11-07 08:08:36

标签: wpf

我应该如何更改wpftoolkit自动完成框的背景。我试着通过订阅enabledchanged事件来改变控件的背景,而这个控件的背景根本没有改变。可以提供任何身体帮助。

<WpfToolkit:AutoCompleteBox x:Name="txtBxSearch" Background="White"  IsTextCompletionEnabled="True" MinimumPrefixLength="0" FilterMode="Contains"  Height="24"  Width="150" KeyDown="txtBxSearch_KeyDown"  >
        <WpfToolkit:AutoCompleteBox.TextBoxStyle>
            <Style TargetType="TextBox">
                <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
                <Setter Property="FocusManager.FocusedElement" Value="{Binding RelativeSource={RelativeSource Self}}"/>                        
                </Style>
        </WpfToolkit:AutoCompleteBox.TextBoxStyle>
    </WpfToolkit:AutoCompleteBox>

1 个答案:

答案 0 :(得分:0)

您可以在XAML中执行此操作:

<toolkit:AutoCompleteBox
            ToolTip="Enter the path of an assembly."
            x:Name="tbAssembly" Height="27" Width="200"
            Populating="tbAssembly_Populating"                          
            >     
            <toolkit:AutoCompleteBox.Style>
                <Style TargetType="toolkit:AutoCompleteBox">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding ElementName=tbAssembly, Path=IsEnabled}" Value="True">
                            <Setter Property="Background" Value="Yellow" />
                            <Setter Property="Foreground" Value="Red" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding ElementName=tbAssembly, Path=IsEnabled}" Value="False">
                            <Setter Property="Background" Value="Black" />
                            <Setter Property="Foreground" Value="Yellow" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </toolkit:AutoCompleteBox.Style>
        </toolkit:AutoCompleteBox>