1
我想制定一個ComboBox
有一個海軍背景與白色文本的樣式,所以我想下拉箭頭也是白色的(我到目前爲止的xaml下面)。如何獲得一個白色的WPF組合框DropDown箭頭顏色?
<Style x:Key="ComboBoxStyle" TargetType="ComboBox">
<Setter Property="Background" Value="{StaticResource headerBrush}"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="BorderBrush" Value="{StaticResource headerBorderBrush}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="MinWidth" Value="100"/>
<Setter Property="Height" Value="21"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Padding" Value="5"/>
<Setter Property="Margin" Value="3"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>
<Style x:Key="ComboBoxItemStyle" TargetType="ComboBoxItem">
<Setter Property="Background" Value="AliceBlue"/>
<Setter Property="Foreground" Value="Navy"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
</Style>
添加代碼來設置ControlTemplate
?
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBox">
<Path x:Name="Arrow" Fill="White"/>
</ControlTemplate>
</Setter.Value>
</Setter>
我真的沒有得到ControlTemplates,但我猜。該示例中的目標類型是一個ToggleButton,它讓我在xaml設計器中出現異常。將其更改爲ComboBox似乎已將整個控件變成白色。有什麼簡單的方法可以解決這個問題(請參閱編輯的代碼)?謝謝 – Berryl 2009-11-09 05:23:16
如果你有Expression Blend,只需右鍵單擊並選擇Edit Template - > Edit a Copy(我認爲這些都是正確的名稱)。否則,您應該使用Reflector和BamlViewer加載項來將XAML從PresentationFramework.Aero.dll中取出,並剪切出您需要的部分。 – 2009-11-09 08:24:05
編輯好的模板存在的問題是它沒有全部的ComboBox的其他功能。當你看看微軟提供的模板時,你會發現它很複雜。複製他們的代碼並進行所需的更改。 – 2009-11-09 08:25:06