Reputation: 2492
I try to make multiline row at ListBox.
So, i read this question and make this xaml:
<ListBox Grid.Row="1" x:Name="lbKeyPhrases" BorderBrush="Gray"
ItemsSource="{Binding Templates}"
IsSynchronizedWithCurrentItem="True"
Focusable="True"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Auto"
HorizontalContentAlignment="Stretch" Grid.ColumnSpan="2"
>
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem Header="Add Word" Click="MenuItem_Click">
<Image Source="/SomeProj.UI.Resources;component/PNGImages/ItemAdd.png"/>
</MenuItem>
</ContextMenu>
</ListBox.ContextMenu>
<ListBox.ItemTemplate>
<DataTemplate>
<DockPanel>
<Border x:Name="brRow" BorderThickness="1" BorderBrush="LightGray"
Background="WhiteSmoke"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<TextBox x:Name="tblbRow"
Text="{Binding Text,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Tag="{Binding}"
GotFocus="tblbRow_GotFocus"
AcceptsReturn="True"
TextWrapping="Wrap" Margin="2"
Focusable="True"
Background="Transparent"
HorizontalAlignment="Stretch"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
>
<TextBox.ContextMenu>
<ContextMenu>
<MenuItem Header="Remove Word"
Click="MenuItem_Click_RemoveTemplate">
<Image Source="/SomeProj.UI.Resources;component/PNGImages/ItemDel.png"/>
</MenuItem>
</ContextMenu>
</TextBox.ContextMenu>
</TextBox>
</Border>
</DockPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
But is seems, that is not work for me. I use TextBox instead TextBlock, because i need to edit line. So, i want if text line will be very large- it wraps to mulitile.
And Scroll not diposed (but should be).
Can you tell me, how to do that?
P.S. it seems that Scroll not disposed,because it is from another Grid.
Upvotes: 0
Views: 1476
Reputation: 7004
As requested, my comment as an answer:
Does a horizontal scrollbar appear when it get's long enough that it should be wrapping? The wrapping is not occuring because the content can scale as much as it wants within the ScrollViewer. Wrapping comes secondary to the control filling all horizontal space, so allowing it to scroll allows it to consume an infinite space.
Setting:
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
in the control containing your textbox (the ListBox) should prevent this behavior.
Upvotes: 1
Reputation: 2492
@Joe was right: upper grid have ScrollView.HorizontalBarVisible:Auto
, so i change it to Disable
and it works!
Upvotes: 0