2014-01-24 2 views
2

저는 XAML과 WPF에 매우 익숙하지만 다음을 시도하고 있습니다.IsExpanded Binding

groupDescription을 기반으로 확장자로 ListView를 빌드합니다. 어느 것이 잘 작동합니다. 이제 응용 프로그램 내에서 탭을 전환하면 이전 사용자가 선택한 확장 및 축소 된 확장기를 선택했기 때문에 IsExpanded 속성을 항목에 바인딩하려고합니다. 즉, 모든 확장자가 기본값으로 되돌려 져서 축소 된 것을 의미합니다. 이는 매우 성가신 일입니다.

그러나 실제로 어떻게 작동하는지 이해하지 못합니다. 확장기의 IsExpanded 속성을 해당 클래스의 속성에 바인딩 할 수 있습니까? 어떻게 다른 그룹을 구별 할 수 있습니까?

<ListView Name="Mails" local:FM.Register="{Binding}" local:FM.GetFocus="Loaded" 
        Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
        ItemsSource="{Binding Path=MailsProxy.View}" 
        SelectionMode="Single" SelectedItem="{Binding Path=SelectedMail, Mode=TwoWay}" 
        local:SortList.BringIntoViewSelected="True" local:SortList.IsGridSortable="True" 
        ItemContainerStyle="{StaticResource InboxMailItem}" 
        View="{Binding Source={x:Static session:Session.Current}, Path=InboxView.View}"> 
      <ListView.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 Foreground="Black" BorderThickness="0,0,0,1" Style="{StaticResource ExpanderStyle}"> 
              <Expander.Header> 
               <DockPanel> 
                <TextBlock FontWeight="Bold" FontSize="14" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=ListView}, Path=DataContext.GroupBy}"/> 
                <TextBlock FontWeight="Bold" FontSize="14">:</TextBlock> 
                <TextBlock FontSize="14" Text="{Binding Path=Name, Converter={StaticResource GroupHeaderConverter}}" Margin="5,0,0,0"/> 
               </DockPanel> 
              </Expander.Header> 
               <ItemsPresenter /> 
             </Expander> 
            </ControlTemplate> 
           </Setter.Value> 
          </Setter> 
         </Style> 
        </GroupStyle.ContainerStyle> 
       </GroupStyle> 
      </ListView.GroupStyle> 
      <ListView.Resources> 
       <Style TargetType="{x:Type GridViewColumnHeader}"> 
        <Setter Property="DataContext" Value="{Binding Source={x:Static session:Session.Current}, Path=InboxView}"/> 
       </Style> 
      </ListView.Resources> 
     </ListView> 

답변

-1

그들에 대한 몇 가지 정적 부울 변수와 설정 속성을 정의 대단히 감사 및 사용자 확장 또는 특정 노드를 축소 할 때 다음 각 부울 변수 값 예는 true = Mails.Expanded 때 U를 할당 페이지의 렌더링이나 페이지로드에서 다시 같은 탭으로 돌아와 정적 변수의 값을 확인하고 Mails.Expanded = isExpanded에 동일한 값을 할당하면 문제가 해결됩니다.

+0

답장을 보내 주셔서 감사합니다. 조금 자세히 설명해 주시겠습니까? – Xeun

-1

코드는 다음과 같습니다. 나는 번째 윈도를 고려하고

static bool isExpanded = false; 

은 목록 뷰 컨트롤이이보기를 취소 할 수

private void Window1_Load(object sender, RoutedEventArgs e) 
{ 
    Mails.Expanded = isExpanded; 
    //... rest of your code 
} 

private void Mails_SelectionChanged(object sender, RoutedEventArgs e) 
{ 
    isExpaned = Mails.Expanded; 
} 

희망이 추가되는 윈도우의 이름입니다.

+0

내가 잘못 본 것이 아니라면 GroupDescription에 의해 생성 된 특정 그룹이 아닌 모든 그룹이 축소되거나 확장됩니다. 그렇지 않습니까? – Xeun

+0

그래, 내가 틀렸을 수도 있지만 방금 당신에게 각 그룹에 대한 확장 플래그의 정적 목록을 만들 수있는 Window_load에서 그 값을 다시 검색하고 각 그룹 확장 속성에 할당 할 수있는 해결책을 제안했습니다.이게 당신의 문제를 해결할 수 있기를 바란다. 더 도움이 필요한 경우 도움을 청하십시오. –

+0

나는 당신에게이 점을 어떻게 달성하고 싶은지 잘 모르겠다. – Xeun