Style.Setters 속성

정의

SetterEventSetter 개체의 컬렉션을 가져옵니다.

public:
 property System::Windows::SetterBaseCollection ^ Setters { System::Windows::SetterBaseCollection ^ get(); };
public System.Windows.SetterBaseCollection Setters { get; }
member this.Setters : System.Windows.SetterBaseCollection
Public ReadOnly Property Setters As SetterBaseCollection

속성 값

SetterBaseCollection

SetterEventSetter 개체의 컬렉션입니다. 기본값은 빈 컬렉션입니다.

예제

다음 예제에서는이 속성을 사용 하는 방법을 보여 있습니다.

Style style = new Style(typeof(ListBoxItem));
style.Setters.Add(new Setter(ListBoxItem.HorizontalContentAlignmentProperty,
     HorizontalAlignment.Stretch));
ListBox lb = new ListBox();
lb.ItemContainerStyle = style;
ListBoxItem lbi1 = new ListBoxItem();
Button btn = new Button();
btn.Content = "Button as styled list box item.";
lbi1.Content = (btn);
lb.Items.Add(lbi1);
Dim style As Style = New Style()
style.Setters.Add(New Setter(ListBoxItem.HorizontalContentAlignmentProperty, _
     HorizontalAlignment.Stretch))
Dim lb As ListBox = New ListBox()
lb.ItemContainerStyle = style
Dim lbi1 As ListBoxItem = New ListBoxItem()
Dim btn As Button = New Button()
btn.Content = "Button as styled list box item."
lbi1.Content = (btn)
lb.Items.Add(lbi1)

추가 SetterBase 자식을 Style 개체가 암시적으로 추가 합니다 SetterBaseCollection 에 대 한를 Style 개체입니다. 다음은 EventSetter 스타일에 SetterBaseCollection 암시적으로 추가됩니다.

<StackPanel
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="SDKSample.EventOvw2"
  Name="dpanel2"
  Initialized="PrimeHandledToo"
>
  <StackPanel.Resources>
    <Style TargetType="{x:Type Button}">
      <EventSetter Event="Click" Handler="b1SetColor"/>
    </Style>
  </StackPanel.Resources>
  <Button>Click me</Button>
  <Button Name="ThisButton" Click="HandleThis">
    Raise event, handle it, use handled=true handler to get it anyway.
  </Button>
</StackPanel>

설명

개체의 속성은 Setters 할당할 수 있는 개체로만 구성됩니다SetterBase.Style 추가 SetterBase 자식을 Style 개체가 암시적으로 추가 합니다 SetterBaseCollection 에 대 한를 Style 개체입니다.

명시적 속성 요소 사용 Setters 도 비교적 일반적입니다. 이는 복잡한 스타일의 항목과 Triggers 구별 Setters Resources 하는 데 도움이 될 수 있는 태그 스타일 결정입니다. 예를 들면 다음과 같습니다.

<Style>  
  <Style.Setters>  
    <!--one or more SetterBase derived object elements here-->  
  </Style.Setters>  
</Style>  

XAML 속성 요소 사용

<object>  
  oneOrMoreSetters  
</object>  

XAML 값

oneOrMoreSetters
하나 이상의 Setter EventSetter 개체입니다.

적용 대상

추가 정보