Click here to Skip to main content
15,912,400 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the following code that creates wpf datagrid with an expander and a button using a Collection view in the cobe behind. I would like to know, how do I select the rows in the expanded group when the Accept Button is clicked.;

XML
<Window.Resources>
        <DataTemplate x:Key="AcceptButton">
            <Button Width="80" Height="20" Content="Accept" Click="Button_Click" />
        </DataTemplate>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Button x:Name="cmdLogin" Content="About" HorizontalAlignment="Left" Margin="1205,13,0,0" VerticalAlignment="Top" Width="55" Background="#FF3DB1C8" FontWeight="Bold" Click="cmdLogin_Click"/>
        <DataGrid x:Name="dgFIFO" HorizontalAlignment="Left" Margin="150,73,0,0" VerticalAlignment="Top" Height="595" Width="430" ItemsSource="{Binding}" RowDetailsVisibilityMode="Visible">
            <DataGrid.GroupStyle>
                <!-- Style for groups at top level. -->
                <GroupStyle>
                    <GroupStyle.ContainerStyle>
                        <Style TargetType="{x:Type GroupItem}">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type GroupItem}">
                                        <Expander IsExpanded="True"  Background="#83D744" HeaderTemplate="{DynamicResource AcceptButton}"   >
                                            <Expander.Header>
                                                <DockPanel Height="25">
                                                    <TextBlock FontWeight="Bold" FontSize="12" Height="15"  Foreground="Black" Text="{Binding Path=Name,StringFormat= AcctNum:# {0}}" />
                                                </DockPanel>
                                            </Expander.Header>
                                            <Expander.Content>
                                                <ItemsPresenter />
                                            </Expander.Content>
                                        </Expander>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </GroupStyle.ContainerStyle>
                </GroupStyle>
            </DataGrid.GroupStyle>



C#
private void cmdProbReview_Click(object sender, RoutedEventArgs e)
        {
            BusinessTier.BLLProbs objbllprobs = new BusinessTier.BLLProbs();
            BusinessTier.Probs objprobs = new BusinessTier.Probs();
            DataSet dsData = new DataSet();

            objprobs.Status = cboStatus.SelectedValue.ToString();
            objprobs.Team = cboTeam.SelectedValue.ToString();

           try
            {
                dsData = objbllprobs.Select_wfSISProbs(objprobs.Status,objprobs.Team);
                
                myprobs.Source = dsData.Tables[0];
                myprobs.GroupDescriptions.Add(new PropertyGroupDescription("AcctNumber"));
                dgFIFO.ItemsSource = myprobs.View;
                
                
            }
            catch(ApplicationException ex)
            {
                System.Windows.MessageBox.Show(ex.Message);
            }
              
        }


What I have tried:

Have not tried much of anything, other then using the collectionview, but at a loss on how to start.
Posted
Updated 31-Oct-16 8:41am
v2

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