将滚动条保持在WPF应用程序的可编辑且不可编辑的文本框中

ABC*_*BCD 4 c# asp.net wpf-controls

在WPF应用程序中,如何根据不同的方案创建一个可编辑或不可编辑的文本框,但仍然有一个滚动条,可以滚动两个场景中的文本.现在文本框配置为:

VerticalScrollBarVisibility="Auto"
IsEnabled="(either False or true)"
Run Code Online (Sandbox Code Playgroud)

现在,即使滚动条出现,我也无法在禁用文本框时滚动文本.

甚至 IsReadOnly没有帮助.

我需要在两个场景中都提供滚动选项.

DLe*_*Leh 7

答案就是按照评论说:不使用IsEnableduse IsReadOnly,而是使用以下setter来获取禁用的样式:

<Setter Property="Panel.Background" TargetName="Bd" Value="{DynamicResource ResourceKey={x:Static SystemColors.ControlBrushKey}}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource ResourceKey={x:Static SystemColors.GrayTextBrushKey}}" />
Run Code Online (Sandbox Code Playgroud)

资源