2010-06-04 3 views
0

내가이어떻게 부모의 재산을 자녀의 재산에 묶을 수 있습니까?

<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="clr-namespace:Groupbox" 
    > 
    <Style TargetType="local:GroupBox"> 
     <Setter Property="BorderBrush" Value="DarkGray"/> 
     <Setter Property="BorderThickness" Value="1"/> 
     <Setter Property="Padding" Value="6"/> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="local:GroupBox"> 
        <Grid Background="{TemplateBinding Background}"> 
         <Grid.RowDefinitions> 
          <RowDefinition Height="Auto"/> 
          <RowDefinition Height="Auto"/> 
          <RowDefinition Height="*"/> 
         </Grid.RowDefinitions> 
         <Border BorderThickness="{TemplateBinding BorderThickness}" Grid.Row="1" Grid.RowSpan="2" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="3"> 
          <Border.Clip> 
           <GeometryGroup FillRule="EvenOdd"> 
            <RectangleGeometry x:Name="FullRect" Rect="0,0,300,200"/> 
            <RectangleGeometry x:Name="HeaderRect" Rect="6,0,100,100"/> 
           </GeometryGroup> 
          </Border.Clip> 
         </Border> 
         <ContentPresenter Grid.Row="2" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Margin="{TemplateBinding Padding}"/> 
         <ContentControl x:Name="HeaderContainer" Margin="6,0,0,0" Grid.Row="0" Grid.RowSpan="2" HorizontalAlignment="Left"> 
          <ContentPresenter Margin="3,0,3,0" ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}"/> 
         </ContentControl> 
        </Grid> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 
</ResourceDictionary> 

같이 정의이고 나는 그래서이

<Controls:GroupBox x:Name="GroupBox"> 
    <Controls:GroupBox.HeaderTemplate> 
    <DataTemplate> 
     <CheckBox "Header" x:Name="cbHeader"/> 
    </DataTemplate> 
    </Controls:GroupBox.HeaderTemplate> 
<Controls:GroupBox> 

같은이 컨트롤을 사용 해요 그룹 상자를 가지고, 음, 내 질문 - 내가 어떻게 그룹 상자의 재산의 IsEnabled 바인딩 할 수 있습니다 확인란 속성 IsChecked에? 미리 감사드립니다.

답변

0

없었다. 이 코드는 같은 방식으로 작동합니다.

<Panels:GroupBox> 
    <Panels:GroupBox.Header> 
    <CheckBox Content="Header" x:Name="cbHeader" IsChecked="{Binding IsHeaderChecked}" /> 
    </Panels:GroupBox.Header> 
    <ContentControl HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" IsEnabled="{Binding Path=IsChecked, ElementName=cbHeader}"/> 
</Panels:GroupBox> 
0

그것을 시도하지 않았나요하지만 당신은 같은 것을 할 수 있어야한다 : 사실 DataTemplate을 정의 할 필요가

<Controls:GroupBox x:Name="MyGroupBox"> 
    <Controls:GroupBox.HeaderTemplate> 
    <DataTemplate> 
     <CheckBox IsChecked="{Binding Path=IsEnabled, ElementName=MyGroupBox, Mode=TwoWay}" Content="Header" x:Name="cbHeader" /> 
    </DataTemplate> 
    </Controls:GroupBox.HeaderTemplate> 
<Controls:GroupBox> 
+0

이 경우 'TemplatedParent'는이 경우 Control 템플릿의 ContentPresenter 인 것처럼 보일 것입니다. – AnthonyWJones

+0

테스트하지 않았습니다. GroupBox 대신 ItemsControl을 사용하여 편집을 수행했지만 개념은 동일합니다. – David

+0

샘플에서 IsChecked를 IsEnabled에 바인딩하고 그 바인딩을 필요로합니다.-IsEnabled를 IsChecked로 지정합니다. – Walkor

관련 문제