Combobox in ListTreeView

Grids for WPF Forum

Posted 3 years ago by Jane
Version: 18.1.0
Avatar

Hi,

I'm new to WPF and ActiPro. Is this the proper way of making combobox columns for a ListTreeView?

                                   <grids:TreeListView x:Name="treeListView" 
                                                        RootItem="{Binding Path=RootItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                                        SelectedItem="{Binding Path=SelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                                        TopLevelIndent="0">
                                        <grids:TreeListView.ItemAdapter>
                                            <OutboardEditorVariables:DefaultTreeListBoxItemAdapter ChildrenBinding="{Binding Children}" ChildrenPath="Children" />
                                        </grids:TreeListView.ItemAdapter>
                                        <grids:TreeListView.Columns>
                                            <grids:TreeListViewColumn Header="Type" Width="*" HeaderHorizontalAlignment="Left" CellHorizontalAlignment="Stretch">
                                                <DataTemplate>
                                                    <ComboBox SelectedItem="{Binding SelectedType}" Width="Auto" Style="{StaticResource comboBoxDefaultStyle}" 
                                                              ItemsSource="{Binding OriginTypes}"/>
                                                </DataTemplate>
                                            </grids:TreeListViewColumn>
                                            <grids:TreeListViewColumn Header="Name" Width="*" HeaderHorizontalAlignment="Left" CellHorizontalAlignment="Stretch" >
                                                <DataTemplate>
                                                    <ComboBox Style="{StaticResource comboBoxDefaultStyle}" ItemsSource="{Binding Names}"/>
                                                </DataTemplate>
                                            </grids:TreeListViewColumn>
                                            <grids:TreeListViewColumn Header="Parameter" Width="*" HeaderHorizontalAlignment="Left" CellHorizontalAlignment="Stretch">
                                                <DataTemplate>
                                                    <ComboBox Style="{StaticResource comboBoxDefaultStyle}" ItemsSource="{Binding Parameters}"/>
                                                </DataTemplate>
                                            </grids:TreeListViewColumn>
                                        </grids:TreeListView.Columns>
                                    </grids:TreeListView>

It works but the combobox is not fully stretched

Comments (2)

Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Jane,

I pasted several columns in a TreeListView in our current version and the ComboBox seems to stretch across the width of the column fine:

<grids:TreeListViewColumn Header="Name" Width="*" HeaderHorizontalAlignment="Left" CellHorizontalAlignment="Stretch" >
	<DataTemplate>
		<ComboBox />
	</DataTemplate>
</grids:TreeListViewColumn>

Maybe start with that and see if you see the same.  If it works in that case, then it might be your ComboBox Style that changes Width, HorizontalAlignment, etc.  Otherwise, it could be something with the older v18.1 you said you were on.  You might want to try the same in v22.1.


Actipro Software Support

Posted 3 years ago by Jane
Avatar

Thank you for the quick reply. I added CellPadding="0" and that worked too. I will try with the latest version as well.

Thanks!

The latest build of this product (v24.1.3) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.