C
C#2y ago
bribri

✅ Problems with wrapping in wpf Listbox

I'm using an listbox to to list multiple options with an image and title. But I want to let my title wrap when smaller etc but I can't seem to do it ... You can see it in image and my code for the box. Should I use listbox for this or an other control? I really need the scroll option for it. (this is still early with some placeholder stuff)
<ListBox Grid.Column="1" ScrollViewer.CanContentScroll="False">
<ListBoxItem>
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="titel" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="WrapWithOverflow"/>
<Image Source="placeholder.png" Width="150" Height="150" HorizontalAlignment="Right"/>
</StackPanel>
</ListBoxItem>
</ListBox>
<ListBox Grid.Column="1" ScrollViewer.CanContentScroll="False">
<ListBoxItem>
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="titel" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="WrapWithOverflow"/>
<Image Source="placeholder.png" Width="150" Height="150" HorizontalAlignment="Right"/>
</StackPanel>
</ListBoxItem>
</ListBox>
5 Replies
HimmDawg
HimmDawg2y ago
What about TextWrapping="Wrap" instead of TextWrapping="WrapWithOverflow"? Also, this seems to be quite a corner case where the text just barely touches the image. You can maybe introduce some margin on the right side with Margin="0, 0, 5, 0" on your textblock
bribri
bribriOP2y ago
tried also doesn't work... Oh yeah wanted to first try to get everything kind of working and then looking for font,size, colors etc
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
bribri
bribriOP2y ago
/close -
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server