We have a list box. Each item is a TextBlock.
If the text too long, it will display as Ellipsis "..." at the end inside textblock.
if the available list is too long, it will display a vertical scroll bar for the listbox.
if the available list can be displayed in one page, the vertical scroll bar will not displayed.
We have difine the
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Width="610"
TextAlignment="Center"
TextTrimming="CharacterEllipsis"
Padding="3,0"
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
Foreground="Black"
Text="{Binding ProgramName}"/>
</DataTemplate>
</ListBox.ItemTemplate>
The problem with this ItemTemplate, we have to define the textBlock's width in order to align the text content in the center and display the Ellipsis if text content is too long. However the real width is different with/without displaying the vertical
scrool bar of listbox. So far we have to base on the vertical scroll bar displayed to decide the textblock's width.
Is there someway, we can fix this problem?
thx!
View Complete Post