Hi,@StreamingMoon. Welcome to Microsoft Q&A.
Reason:CaretBrush
is a property of TextBoxBase
, and TextBlock
does not inherit TextBoxBase
, so it does not have a CaretBrush
property.
Solution: Adjust code
<ScrollViewer
Margin="0"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Disabled">
<TextBlock
Margin="2,0,2,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="15"
Foreground="{TemplateBinding Foreground}"
Text="{Binding Path=Text, RelativeSource={RelativeSource TemplatedParent}}" />
</ScrollViewer>
To
<ScrollViewer
x:Name="PART_ContentHost"
Margin="2,0,2,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="15"
Foreground="{TemplateBinding Foreground}"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Disabled">
</ScrollViewer>
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.