[英]RichTextBox scrollbar image as background c# wpf
I want to have image as background in my richtextbox command. 我想在我的richtextbox命令中将图像作为背景。 I'm using, but I can only set background value to already defined colors, not images. 我正在使用,但是我只能将背景值设置为已经定义的颜色,而不是图像。 (I were using scrollbarviewer but it doesnt show in my 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>
The Value can be any object, so it can be an ImageBrush. 该值可以是任何对象,因此可以是ImageBrush。 You can do it with the element syntax. 您可以使用元素语法来实现。
<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>
Try like this- 尝试这样-
<RichTextBox>
<RichTextBox.Background>
<ImageBrush ImageSource="some.jpg"/>
</RichTextBox.Background>
</RichTextBox>
See if this helps. 看看是否有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.