2016-11-10 53 views
1

朋友 我覺得這個代碼,以使圓組合框,但我不知道如何使用輪組合框的邊框

沒有任何人可以幫助如何使用此代碼

<Style TargetType="{x:Type ComboBox}">  
    <Setter Property="Template"> 
    <Setter.Value> 
     <ControlTemplate TargetType="{x:Type ComboBox}"> 
     <Border CornerRadius="5"> 

     </Border> 
     </ControlTemplate> 
    </Setter.Value> 
    </Setter> 
</Style> 

什麼我應該把這個代碼應用到我的組合框中wpf

+0

https://blogs.msdn.microsoft.com/wpfsldesigner/2010/06/03/creating-and-consuming-resource-dictionaries-in-wpf-and-silverlight/ – Steve

+0

您需要覆蓋組合框模板。 – Jim

+0

右鍵單擊'ComboBox'>編輯模板>編輯複製,並根據您的意願更改模板。 – AnjumSKhan

回答

0

這個模板,你在這裏顯示只是一個基本的想法,但不是真的工作。您需要覆蓋完整的默認模板並根據您的需要對其進行自定義。裏面你UserControl的資源屁股模板從這個鏈接default combobox template

<UserControl.Resources> 
<!-- paste the code here--> 
<!--Control colors.--> 
<Color x:Key="WindowColor">#FFE8EDF9</Color> 
<Color x:Key="ContentAreaColorLight">#FFC5CBF9</Color> 
<Color x:Key="ContentAreaColorDark">#FF7381F9</Color> 

…. 

<ControlTemplate x:Key="ComboBoxToggleButton" 
       TargetType="{x:Type ToggleButton}"> 
…. 

</UserControl.Resources> 
Then modify the border radius in two places: 
… 
Grid.ColumnSpan="2" 
      CornerRadius="<put a new radius here, for example 20>" 
      BorderThickness="1"> 
… 
And here 
<Border Grid.Column="0" 
      CornerRadius="<new value, for example 20>,0,0,<new value, for example 20>" 
      Margin="1" > 

這應該這樣做(只是複製和粘貼)。由於您未指定模板的鍵名稱,因此組合框應自動選取新模板。