AnKor
Topic Author
Posts: 25
Joined: 22 Jul 2022, 16:14

CharacterSpacing is not inherited from container

06 May 2024, 12:28

Hi!

TextBlock element has some magic (which I still don't fully understand) that allows it to inherit various properties from ContentControl.
For example here it inherits foreground and font size from Button.
However this magic doesn't seem to work with CharacterSpacing attached property (using latest Noesis 3.2.3).
  <StackPanel>
    <Button Width="300">
      <TextBlock Foreground="Blue" FontSize="30" noesis:Text.CharacterSpacing="1000">Test</TextBlock>
    </Button>
    <Button Width="300" Foreground="Blue" FontSize="30" noesis:Text.CharacterSpacing="1000" Content="Test" />
  </StackPanel>
So far I worked around this issue by setting TextBlock's style like this in ContentPresenter's resources:
  <Style TargetType="TextBlock">
    <Setter Property="noesis:Text.CharacterSpacing" Value="{Binding (noesis:Text.CharacterSpacing), RelativeSource={RelativeSource AncestorType=ContentControl}}"/>
  </Style>
but this is really ugly.

Is it a bug or by design? And maybe there is a better workaround I missed?
 
User avatar
sfernandez
Site Admin
Posts: 3033
Joined: 22 Dec 2011, 19:20

Re: CharacterSpacing is not inherited from container

06 May 2024, 17:50

The property is not registered with the Inherits flag, this is not correct.
Could you please create a ticket in our bugtracker and we will fix it?

Your workaround is the best solution right now.
 
AnKor
Topic Author
Posts: 25
Joined: 22 Jul 2022, 16:14

Re: CharacterSpacing is not inherited from container

06 May 2024, 20:11

Created #3301.
Thank you!

So the "magic" is just the Inherits flag? Interesting, I knew about the flag, but I thought there's something special in the TextBlock itself.
 
User avatar
sfernandez
Site Admin
Posts: 3033
Joined: 22 Dec 2011, 19:20

Re: CharacterSpacing is not inherited from container

06 May 2024, 21:49

So the "magic" is just the Inherits flag? Interesting, I knew about the flag, but I thought there's something special in the TextBlock itself.
Yes, only that... this was an easy fix :)

Who is online

Users browsing this forum: Google [Bot] and 15 guests