我想在我的richtextbox命令中将图像作为背景。我正在使用,但是我只能将背景值设置为已经定义的颜色,而不是图像。(我使用的是scrollbarviewer,但未在我的richtextbox中显示)
<RichTextBox x:Name="richTextBox" HorizontalAlignment="Left" Height="285" VerticalAlignment="Top" Width="880" VerticalScrollBarVisibility="Visible" IsReadOnly="True" Foreground="#FFA02626" Background="{x:Null}">
<RichTextBox.Resources>
<Style TargetType="ScrollBar">
<Setter Property="Background" Value="Red"/>
</Style>
</RichTextBox.Resources>
</RichTextBox>
该值可以是任何对象,因此可以是ImageBrush。您可以使用元素语法来做到这一点。
<RichTextBox x:Name="richTextBox" HorizontalAlignment="Left" Height="285" VerticalAlignment="Top" Width="880" VerticalScrollBarVisibility="Visible" IsReadOnly="True" Foreground="#FFA02626" Background="{x:Null}">
<RichTextBox.Resources>
<Style TargetType="ScrollBar">
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="cool-northern-lights-pic-4.jpg"/>
</Setter.Value>
</Setter>
</Style>
</RichTextBox.Resources>
</RichTextBox>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句