Megamax5000
Topic Author
Posts: 3
Joined: 15 Feb 2018, 22:23

Is there a way to set TextBox ScrollBar to be at the bottom?

17 Apr 2018, 21:15

Have dug around a bit an cannot find a solution to the problem. I have a TextBox that looks like this:
<TextBox 
                    x:Name="BattleLogBox" 
                    Grid.Column="2" 
                    VerticalScrollBarVisibility="Auto"
                    ScrollViewer.CanContentScroll="True"
                    MaxLines="6" MinLines="4"
                    TextWrapping="Wrap" 
                    Text="{Binding BattleText, Mode=OneWay}"/>
Every end of turn, this is populated with a play-by-play of the most recent turn. I would like the TextBox to start each turn scrolled all the way to the bottom rather than it's default which is starting at the top. I know that TextBox in xaml has the ScrollToEnd() method, but I can't get that to work in Noesis. When I try I get this error:

Assets/drawgame/XamlUI/Resources/GameHud.xaml.cs(45,23): error CS1061: Type `Noesis.TextBox' does not contain a definition for `ScrollToEnd' and no extension method `ScrollToEnd' of type `Noesis.TextBox' could be found. Are you missing an assembly reference?


Any work around for this?
 
User avatar
sfernandez
Site Admin
Posts: 1911
Joined: 22 Dec 2011, 19:20

Re: Is there a way to set TextBox ScrollBar to be at the bottom?

18 Apr 2018, 14:37

ScrollToEnd method and similar are not implemented in Noesis TextBox yet, could you please create a ticket in our bugtracker to report it?

The workaround will be to look for the ScrollViewer inside TextBox template (using GetTemplateChild if you named it or iterate its children with VisualTreeHelper), and then use the ScrollViewer methods directly.
 
Megamax5000
Topic Author
Posts: 3
Joined: 15 Feb 2018, 22:23

Re: Is there a way to set TextBox ScrollBar to be at the bottom?

18 Apr 2018, 22:35

Awesome, I just decided to use a ScrollViewer instead of a TextBox and then the ScrollViewer.ScrollToBottom() method worked just fine.

Added a bug as well. Thanks!
 
User avatar
sfernandez
Site Admin
Posts: 1911
Joined: 22 Dec 2011, 19:20

Re: Is there a way to set TextBox ScrollBar to be at the bottom?

20 Apr 2018, 11:19

Thanks for the report.

Who is online

Users browsing this forum: No registered users and 0 guests