如何使TextBox在WPF中滚动
答
对于一个文本框设置了以下属性:
<TextBox AcceptsReturn="True"
VerticalScrollBarVisibility="Auto"/>
你说:
I have tried this but it is not working <Label Content="Log Details" Grid.Row="4" ></Label> <Border Margin="7,7,7,3" Grid.Row="5"> <ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="5" > <StackPanel > <TextBox Margin="5" AcceptsReturn="True" VerticalScrollBarVisibility="Visible" IsReadOnly="True" x:Name="LogDetails"></TextBox> </StackPanel> </ScrollViewer> </Border> I am putting this in headercontrol. – jolly
其实,你不”因为TextBox已经在其Template中关联了一个ScrollViewer,所以需要将一个TextBox放入一个ScrollViewer中。 但是,如果你有在你需要做同样的你的具体要求,你可以尝试这样的事:
<Label Content="Log Details" Grid.Row="4" ></Label>
<Border Margin="7,7,7,3" Grid.Row="5">
<ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="5" >
<StackPanel>
<TextBox Margin="5" TextWrapping="Wrap" AcceptsReturn="True" IsReadOnly="True" x:Name="LogDetails"></TextBox>
</StackPanel>
</ScrollViewer>
</Border>
答
尝试:
<ScrollViewer>
<Textbox/>
</ScrollViewer>
我都试过,但它不工作 ScrollViewer> 我把它放在headercontrol中。 –
jolly
2009-11-17 06:36:49