[英]RichTextBox scrollbar image as background c# wpf
我想在我的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>
嘗試這樣-
<RichTextBox>
<RichTextBox.Background>
<ImageBrush ImageSource="some.jpg"/>
</RichTextBox.Background>
</RichTextBox>
看看是否有幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.