Click here to Skip to main content
15,886,094 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm trying out a DataGrid with a RowDetailsTemplate. It appears as I wish but how can I close it if I don't want to see it anymore? I thought I can use the MouseLeftButtonDown event on the StackPanel inside my RowDetailsTemplate (s. below) but is that good choice? And if so, what have I to do in the event handler?

XML
<Grid>
           <DataGrid >
               <DataGrid.RowDetailsTemplate>
                   <DataTemplate>
                       <StackPanel Background="Beige" MouseLeftButtonDown="StackPanel_MouseLeftButtonDown">
                           <TextBlock Text="Description" FontWeight="Bold"/>
                           <TextBlock Text="{Binding Description}"/>
                           <TextBlock Text="Benefit" FontWeight="Bold"/>
                           <TextBlock Text="{Binding LongBenefit}"/>
                           <TextBlock Text="Special" FontWeight="Bold"/>
                           <TextBlock Text="{Binding Special}"/>
                       </StackPanel>
                   </DataTemplate>
               </DataGrid.RowDetailsTemplate>
               <DataGrid.Columns>
                   ...
               </DataGrid.Columns>
           </DataGrid>
       </Grid>


Bye,

Stefan
Posted
Comments
Mark Salsbery 26-Jul-11 17:28pm    
By default, RowDetailsVisibilityMode is VisibleWhenSelected. So you can unselect a row by ctrl-click. What are you doing in your mousedown handler? You'd need to find the row and set its DetailsVisibility to Collapsed I believe.
Alpman 28-Jul-11 9:18am    
Thanks for the info. For the time being I'm fine with the ctrl-click-option.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900