2010-08-20 7 views
0

어떻게하면 좋을까요?WPF - 스타일에서 Grid의 자식을 설정하는 방법?

<Style TargetType="Grid"> 
    <Setter Property="Children"> 
     <Setter.Value> 
     ... 
     </Setter.Value> 
    </Setter> 
</Style> 

나는 읽기 전용으로 아이들을 알고 있으며, 아이들에게 "쓰기 가능한 속성이 필요합니다"라고 알려줍니다.

감사

Panel.ChildrenDependencyProperty하지 않기 때문에 당신은 할 수 없습니다
+0

당신은 아무것도에 그리드 항목을 바인딩 그리드 포함하는 자사의 템플릿/ContentTemplate 속성을 설정할 수 있습니다? – Rachel

+0

레이첼, 아니에요. 구속력있는 형태의 스타일링. 이것이 제가 효과가 없다고 생각하는 이유입니다. 아이들은 DP가 아니기 때문에 바인딩에 사용할 수 없으며 스타일 또한 구속력이 있습니다. –

답변

3

. 거의 확실하게 ItemsControl을 사용자 정의 ItemsPanel과 함께 사용하려고합니다. 그러나 더 많은 정보없이 나는 정말로 말할 수 없었다.

1

대신 그리드의 ContentControl을을 사용하고,은 ControlTemplate/DataTemplate을이

<ContentControl> 
    <ContentControl.Style> 
     <Style TargetType="ContentControl"> 
      <Setter Property="Template"> 
       <Setter.Value> 
       <ControlTemplate> 
       <Grid> 
       ... 
       </Grid> 
       </ControlTemplate> 
       </Setter.Value> 
      </Setter> 
     </Style> 
    </ContentControl.Style> 
</ContentControl> 

또는

<ContentControl> 
    <ContentControl.Style> 
     <Style TargetType="ContentControl"> 
      <Setter Property="ContentTemplate"> 
       <Setter.Value> 
       <DataTemplate> 
       <Grid> 
       ... 
       </Grid> 
       </DataTemplate> 
       </Setter.Value> 
      </Setter> 
     </Style> 
    </ContentControl.Style> 
</ContentControl> 
관련 문제