Letterspacing (tracking) with TextBlock in WPF?

What is the best way to take note notes (tracking) using TextBlock in WPF?

I would have thought that TextBlock.Typography would take care of this, but it is not. What is the best approach?

+3
source share
2 answers

It seems that this problem cannot be solved easily. You can google and find something like this http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/789c3e1b-e3ae-476f-b37f-d93ef6d0cb7b/ (approach with glyphs). But taking into account the fact that String is an enumerated collection, sometimes you can solve your problem with markup as follows:

<Grid>
    <ItemsControl>
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <UniformGrid Rows="1"/>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemsSource>
            <System:String>
                Hello World
            </System:String>
        </ItemsControl.ItemsSource>
    </ItemsControl>         
</Grid>

(, ) . , , UserControl. , .

0

, , , , , .

UniformGrid . .

:

<Grid>
    <ItemsControl ItemsSource="{Binding SomeString}" HorizontalAlignment="Center" VerticalAlignment="Center">
            <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal" />
                        </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemContainerStyle>
                        <Style>
                            <Setter Property="Control.Margin" Value="1,0,0,0"/>
                            <Setter Property="Control.Foreground" Value="#1E395B"/>
                         </Style>
                </ItemsControl.ItemContainerStyle>
        </ItemsControl>
</Grid>
0

Source: https://habr.com/ru/post/1768699/


All Articles