TreeListBox: ItemTemplate margin

Grids for WPF Forum

Posted 3 years ago by Ed
Version: 20.1.0
Avatar

I'm using a TreeListBox with a simple ItemTemplate, our customers are requesting the tree view is made "more compact".

How can I reduce the apparent margin around each instance (I've added the Aqua highlight to show the vertical whitespace I'd like to reduce).

https://imgur.com/a/bs45VRD

[Modified 3 years ago]

Comments (1)

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

Hello,

That margin looks larger than it should be by default.  For instance with a basic ItemTemplate like this in our Getting Started QuickStart:

<grids:TreeListBox.ItemTemplate>
	<DataTemplate>
		<StackPanel Orientation="Horizontal">
			<shared:DynamicImage Width="16" Height="16" Source="{Binding ImageSource}" Stretch="None" VerticalAlignment="Center" />
			<TextBlock Margin="4,0,0,0" Text="{Binding Name}" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" />
		</StackPanel>
	</DataTemplate>
</grids:TreeListBox.ItemTemplate>

I'm seeing a total item height of 20px when it is selected.  Your item height (the Aqua part) also appears to be 20px tall, but perhaps something is spacing out the items? 

The panel we use in TreeListBox is simply a VirtualizingStackPanel and I don't believe we have anything that sets item margins.  I wonder if some other Style in your app is affecting things, such as do you have some style that sets additional Margin/Padding on TreeListBoxItem?

Or could it be that you set an Expander Style that is more than 20px tall?

If you have trouble tracking it down, first see how things look in our sample project.  Do you see same large item spacing or is it more compact like it should be?


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.