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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With