2014-11-01 2 views
0

Как я могу изменить последнее свойство ControlTemplate? в следующем коде, я хочу изменить последнее свойство Expander на True. Я имею в виду первое, второе, третье и ... свойство Expander является ложным, а последнее - True.Как я могу изменить последнее свойство ControlTemplate

<Expander IsExpanded="False" BorderBrush="Aquamarine" BorderThickness="1"> 

мой код так:

<ScrollViewer 
    x:Name="scrollviewer" 
    Height="300" 
    Width="270" 
    VerticalScrollBarVisibility="Auto" 
    VerticalAlignment="Top" 
    CanContentScroll="True" > 
    <ItemsControl x:Name="lstComment" FlowDirection="RightToLeft"> 
     <ItemsControl.ItemTemplate> 
     <DataTemplate> 
      <StackPanel Orientation="Horizontal"> 
       <TextBlock Text="{Binding Path=count}" /> 
       <TextBlock Text=" " /> 
       <TextBlock Text="{Binding Path=comment}" /> 
       <TextBlock Text=" " /> 
       <TextBlock Text="{Binding Path=RedSentence}" Foreground="Red"/> 
       <TextBlock Text=" " /> 
       <TextBlock Text="{Binding Path=BlueSentence}" Foreground="Blue"/> 
       <TextBlock Text=" " /> 
      </StackPanel> 
     </DataTemplate> 
     </ItemsControl.ItemTemplate> 
     <ItemsControl.GroupStyle> 
     <GroupStyle> 
      <GroupStyle.ContainerStyle> 
       <Style TargetType="{x:Type GroupItem}"> 
        <Setter Property="Margin" Value="0,0,0,5" /> 
        <Setter Property="Template"> 
        <Setter.Value> 
         <ControlTemplate TargetType="{x:Type GroupItem}"> 
          <Expander IsExpanded="False" BorderBrush="Aquamarine" BorderThickness="1"> 
           <Expander.Header> 
           <DockPanel Background="Yellow"> 
            <TextBlock FontWeight="Bold" Text="{Binding Name}" Margin="5,0,0,0" Width="200" /> 
            <TextBlock FontWeight="Bold" Text="{Binding ItemCount}" /> 
           </DockPanel> 
           </Expander.Header> 
           <Expander.Content> 
           <Border BorderBrush="Red" BorderThickness="2" CornerRadius="5"> 
            <ItemsPresenter /> 
           </Border> 
           </Expander.Content> 
          </Expander> 
         </ControlTemplate> 
        </Setter.Value> 
        </Setter> 
       </Style> 
      </GroupStyle.ContainerStyle> 
     </GroupStyle> 
     </ItemsControl.GroupStyle> 
    </ItemsControl> 
</ScrollViewer> 

ответ

0

Попытка добавить новое логическое свойство класса GroupItem. Это свойство укажет, расширился ли Expander для этого GroupItem или нет. Затем вы можете привязать свойство Expander IsExpanded к свойству GroupItem.

+0

Спасибо. Вы можете привести пример? –

Смежные вопросы