Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keeping the scrolling bar in editable and non-editable text box of WPF application

In a WPF application how can I have a Text box which can be editable or not editable according different scenarios but still have a scroll bar which enables to scroll through the text in both the scenarios. Right now the text box is configured as:

VerticalScrollBarVisibility="Auto"
IsEnabled="(either False or true)"

Now even though the scroll bar appears i am unable to scroll through the text when the text box is disabled.

Even IsReadOnly does not helps.

I need the scrolling option available in both the scenarios.

like image 735
ABCD Avatar asked Feb 17 '23 16:02

ABCD


1 Answers

The answer to this is to do as the comments say: instead of using IsEnabled use IsReadOnly, and use the following setters to get the disabled style:

<Setter Property="Panel.Background" TargetName="Bd" Value="{DynamicResource ResourceKey={x:Static SystemColors.ControlBrushKey}}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource ResourceKey={x:Static SystemColors.GrayTextBrushKey}}" />

source

like image 88
DLeh Avatar answered Apr 30 '23 05:04

DLeh