Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Linecount not increasing in Iwpftextview while word wrap enabled

$
0
0

Hello Friends,

I am using IWpfTextView and want to show vertical scrollbar in textbuffer(whenever required)

Here is my code

private void SetScrollBarVisibilty()
        {

IWpfTextViewMargin verticalScrollBar = wpfTextViewHost.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar) as IWpfTextViewMargin;
            if (verticalScrollBar != null)
            {
                double actuaWidth = ((((wpfTextViewHost.TextView).TextViewLines).LastVisibleLine).VisibleArea.Height / wpfTextView.LineHeight);
                char lasstChar = new char();
                if (this.Text != string.Empty)
                    lasstChar = this.Text.Last();
                if ((actuaWidth <= textBuffer.CurrentSnapshot.LineCount) ||
                   (Math.Truncate(actuaWidth) <= (wpfTextViewHost.TextView).TextViewLines.Count) ||
                   (Math.Truncate(actuaWidth) <= (wpfTextViewHost.TextView).TextViewLines.Count && lasstChar.Equals('\n')))
                {
                    verticalScrollBar.VisualElement.Visibility = System.Windows.Visibility.Visible;
                }
                else if (verticalScrollBar.VisualElement.Visibility == System.Windows.Visibility.Visible && actuaWidth > textBuffer.CurrentSnapshot.LineCount)
                    verticalScrollBar.VisualElement.Visibility = System.Windows.Visibility.Collapsed;
            }

}

The problem is with line count (textBuffer.CurrentSnapshot.LineCount) not increasing because word wrap is enabled.Any one have any idea how to diaplay scroll bar when needed on the basis of coordinate of text buffer or some how else.

Thanks in advance.

Rushikesh.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>