Home > Enterprise >  How to overlay Segoe MDL2 Assets glyphs for use in WPF TreeViewItem.Header?
How to overlay Segoe MDL2 Assets glyphs for use in WPF TreeViewItem.Header?

Time:10-25

I just read about overlaying glyphs. I am trying it out. This is the simplified xaml portion to compose the TreeViewItem.Header

<TreeViewItem.Header>
  <StackPanel Orientation="Horizontal">
    <TextBlock Name="icon" FontFamily="Segoe MDL2 Assets"
       Text="&#xED0D;" Foreground="Blue" Background="cyan" />
    <TextBlock Name="title"/>
  </StackPanel>
</TreeViewItem.Header>

It produces a header containing glyph ED0D like this:
enter image description here

However, I would like to overlay ED0C enter image description here onto glyph ED0D.

What avenues are available to me to perform such overlay to be used in the TreeViewItem.Header?

CodePudding user response:

Put two TextBlocks on top of each other:

<StackPanel Orientation="Horizontal">
    <Grid TextElement.FontFamily="Segoe MDL2 Assets">
        <TextBlock Text="&#xED0C;" Foreground="Cyan"/>
        <TextBlock Text="&#xED0D;" Foreground="Blue"/>
    </Grid>

   <TextBlock x:Name="title"/>
</StackPanel>

Result:

enter image description here

  • Related