Micro Focus QTP (UFT) Forums
[UFT] [WPF] DataGrid: get items of ControlTemplate - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: [UFT] [WPF] DataGrid: get items of ControlTemplate (/Thread-UFT-WPF-DataGrid-get-items-of-ControlTemplate)



[UFT] [WPF] DataGrid: get items of ControlTemplate - robertosalemi - 07-14-2016

Hi,
i'm testing a WPF application.

I have the source code:
Code:
<DataGrid.GroupStyle>
    <GroupStyle>
        <GroupStyle.Panel>
            <ItemsPanelTemplate>
                <DataGridRowsPresenter/>
            </ItemsPanelTemplate>
        </GroupStyle.Panel>
        <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 Name="GroupLot" Loaded="GroupLot_Loaded" Expanded="GroupLot_Expanded" Collapsed="GroupLot_Collapsed" BorderThickness="1,1,1,5">
                                <Expander.Header>
                                    <Grid HorizontalAlignment="Stretch">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="*" />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>

                                        [...]
                                        
                                        <TextBlock Grid.Column="1" FontWeight="Bold" Margin="10,0,0,0" Width="Auto" VerticalAlignment="Center" Foreground="White">
                                            <Run>Description:</Run>
                                            <Run>
                                                <Run.Text>
                                                    <MultiBinding Converter="{StaticResource TypeLot}" Mode="OneWay">
                                                        <Binding Path="Name" />
                                                        <Binding Path="DataContext" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}"/>
                                                    </MultiBinding>
                                                </Run.Text>
                                            </Run>
                                        </TextBlock>
                                        
                                    </Grid>
                                </Expander.Header>
                                <Expander.Content>
                                    <ItemsPresenter Visibility="{Binding ElementName=GroupLot, Path=IsExpanded, Converter={StaticResource BoolToVis}}" />
                                </Expander.Content>
                            </Expander>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </GroupStyle.ContainerStyle>
    </GroupStyle>
</DataGrid.GroupStyle>

I worte this code for get ControlTemplate:
Code:
WpfWindow("myApp").WpfTable("gridLots").Object.GroupStyle.Item(0).ContainerStyle.Setters.Item(1).Value

but, how can I get the expander and the TextBlock into it?

Thanks.