2012-07-17 5 views
7

그래서 Expression Blend에서 내 콤보 상자의 스타일을 변경하려고합니다. WPF 콤보 상자의 테두리 색 변경

은 내가 한 것은 복사

을 편집하고 배경 사이에 흰색 테두리가 제외 내가 콤보 상자의 색상을 변경할 수 있습니다> 콤보를 만들 수 있었고, 마우스 오른쪽 단추> 편집 템플릿을 갔다 콤보 박스의 국경. 당신이 볼 수 있도록 여기 화면은 다음과 같습니다

enter image description here

당신이 볼 수 있듯이, 파란색과 빨간색 사이에 잠시 국경이있다. 지금까지 내가 말할 수있는 코드는 다음 콤보 상자의 색상을한다 변경하려면 :

<ToggleButton Grid.ColumnSpan="2" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, 
RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource 
ComboBoxReadonlyToggleButton}" BorderBrush="Red" Background="Blue"/> 

하지만, 항상 흰색 테두리가있다 상관없이. 나는 그것을 어떻게 제거합니까?

답변

0

복사본을 편집 할 때 Microsoft의 크롬 구성 요소가 내장 된 사본을 편집하는 것이 문제입니다. 외부 테두리를 변경하려면 해당 비트를 일반 WPF 컨트롤로 바꿔 값을 변경할 수 있어야합니다. 콤보 상자를 들어, 여기에 코드를 사용하려는 것 : http://msdn.microsoft.com/en-us/library/ms752094

전자 : 이것은 내가이 오래된 질문 알고

<Border x:Name="Border" 
     Grid.ColumnSpan="2" 
     CornerRadius="2" 
     BorderThickness="1"> 
    <Border.BorderBrush> 
    <LinearGradientBrush EndPoint="0,1" 
         StartPoint="0,0"> 
     <GradientStop Color="{DynamicResource BorderLightColor}" 
        Offset="0" /> 
     <GradientStop Color="{DynamicResource BorderDarkColor}" 
        Offset="1" /> 
    </LinearGradientBrush> 
    </Border.BorderBrush> 
1

을 편집 할 부분이며,이 혼합 특정입니다하지만 때 이 문제에 대한 인터넷 검색, 내가 찾은 첫 번째 것들 중 하나입니다.

이 간단한 문제를 해결하는 방법의 간단한 예는 위에서 언급 한 첫 번째 대답보다 조금 덜 복잡합니다. "스타일"속성을 설정하는 것입니다. (블렌드를 사용하지 않기 때문에 블렌드를 적용하지는 않지만 Visual Studio의 wpf는 간단합니다.)

예를 들어 아래 코드는 질문에 언급 된 것과 같은 창이 생성되지만 흰색 선 (드롭 다운 항목에서)을 편집 할 수 있습니다.

<ComboBox Background="Blue" BorderBrush="Red"> 
    <ComboBox.ItemContainerStyle> 
     <!-- Without this style section, there are white lines around the borders. Even if you set these properties in the comboBoxItem areas --> 
     <Style TargetType="ComboBoxItem"> 
      <Setter Property="Background" Value="Green"/> 
      <Setter Property="BorderBrush" Value="Purple"></Setter> 
     </Style> 
    </ComboBox.ItemContainerStyle> 
    <ComboBoxItem MouseMove="schedule" Name="cbi1">schedule</ComboBoxItem> 
</ComboBox>