2016-09-15 11 views
0

WPFプロジェクトの新しい種類のxamlは本当に混乱します。C#XAMLグリッドエキスパンダ

グループ化されたListCollectionViewを表示するデータグリッドがあり、グループ化されたビューが折りたたまれるようにクリックボタンが必要です。 (多分それはあまりにも簡単です?)単一の例では、このウォークスルーすることがない達成するために簡単な機能のようですが、過去の日のためにどこでも検索

ここに私のXAML

<Window.Resources> 
    <Style x:Key="GroupHeaderStyle" TargetType = "{x:Type GroupItem}"> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="{x:Type GroupItem}"> 
        <Expander x:Name="myExpander" IsExpanded="True" 
           Background="LightBlue" 
           Foreground="Black"> 
         <ItemsPresenter /> 
        </Expander> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 
</Window.Resources> 
ためのコードがあります

とmainwindow.xaml.cs

  ListCollectionView collection = new ListCollectionView(dt.DefaultView); 
     collection.GroupDescriptions.Add(new PropertyGroupDescription("Grouping")); 

     dataGrid1.ItemsSource = collection; 

に助けてください。どうもありがとうございました。

+0

リストビューを直接エクスパンダコントロールに配置しないでください。 – Versatile

答えて

0

GroupStyleを上書き/設定します。しかし、あなたのサンプルコードはかなりokに見える - だから多分私はちょうどあなたの問題が何であるかを理解していない。

<ItemsControl> 
      <ItemsControl.GroupStyle> 
       <GroupStyle> 
        <GroupStyle.ContainerStyle> 
         <Style TargetType="{x:Type GroupItem}"> 
          <Setter Property="Template"> 
           <Setter.Value> 
            <ControlTemplate TargetType="{x:Type GroupItem}"> 
             <Expander IsExpanded="true" Header="Yolo"> 
              <ItemsPresenter /> 
             </Expander> 
            </ControlTemplate> 
           </Setter.Value> 
          </Setter> 
         </Style> 
        </GroupStyle.ContainerStyle> 
       </GroupStyle> 
      </ItemsControl.GroupStyle> 
     </ItemsControl> 

Plsは、あなたが探しているものでない場合、追加情報を追加します。

関連する問題