Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to get the wpf templated combobox items using test stack white #645

Open
SaiPasumarthy opened this issue Apr 5, 2019 · 0 comments

Comments

@SaiPasumarthy
Copy link

We are using Test stack white to automate our wpf application.
I'm trying to get the items in templated combobox. The combobox sytle and combobox usage given below.

Template Code:

<Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ComboBox}">
                    <Border x:Name="myEDVTypeComboboxBorder"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid x:Name="myEDVTypeComboboxGrid" SnapsToDevicePixels="True" IsSharedSizeScope="True"
                              Background="{DynamicResource  EDVTypeComboBoxStyle.Background}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Popup x:Name="myEDVTypeComboboxPopup" AllowsTransparency="True"
                                   IsOpen="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"
                                   PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"
                                   Placement="Bottom" Margin="1">
                                <Border x:Name="myEDVTypeComboboxPopupBorder"
                                        Background="{DynamicResource EDVTypeComboBoxStyle.Background}"
                                        BorderBrush="{DynamicResource EDVTypeComboBoxStyle.BorderBrush}"
                                        BorderThickness="1.1">
                                    <ListBox x:Name="myEDVTypeListBox"
                                             SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                             Width="{TemplateBinding ActualWidth}"
                                             ItemsSource="{TemplateBinding ItemsSource}"
                                             SelectedItem="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem}"
                                             Style="{StaticResource DataTypeDescriptionListBoxStyle}" />
                                </Border>
                            </Popup>
                            <ContentPresenter x:Name="myEDVComboboxContentPresenter" Grid.Column="0"
                                              IsHitTestVisible="True"
                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              Margin="{TemplateBinding Padding}"
                                              Content="{TemplateBinding SelectionBoxItem}"
                                              ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                                              ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" />
                            <ToggleButton x:Name="myEDVComboboxExpanderArrowToggleButton" Grid.Column="1"
                                          Background="{TemplateBinding Background}"
                                          BorderBrush="{TemplateBinding BorderBrush}"
                                          Style="{StaticResource EDVTypeComboBoxReadonlyToggleButtonStyle}"
                                          IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" />
                            <ToggleButton x:Name="myEDVComboboxExpanderToggleButton"
                                          Background="{TemplateBinding Background}"
                                          BorderBrush="{TemplateBinding BorderBrush}"
                                          Style="{StaticResource EDVTypeComboBoxExpanderToggleButtonStyle}"
                                          IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" />
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

Usage :

<ComboBox x:Name="myMM_GEV_TypeComboBox" Grid.Column="1"
                                              ItemsSource="{Binding Source={StaticResource DataTypeFromEnum}}"
                                              SelectedValue="{Binding SelectedBindingGroupElement.DataType, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                              Style="{StaticResource EDVTypeComboBoxStyle}"
                                              AutomationProperties.AutomationId="MM_GEV_TypeComboBox" />

and i'm trying to get the combobox element items by using below code:

             `var aTypeComboBox = AppHandler.AppWindow.Get<ComboBox>(SearchCriteria.ByAutomationId("MM_GEV_TypeComboBox"));`

aTypeCombBox is exists but inside items are coming zero.

Any help would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant