I'm using this code:
List<TextBlock> BackTextBlocks = new List<TextBlock>();
List<String> AStringList = new List<String>();
...
for (int i = 0; i < TotalCount; i ){
BackTextBlocks.Add(new TextBlock());
BackTextBlocks[i].Text = AStringList[i];
BackTextBlocks[i].Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
BackTextBlocks[i].Arrange(new Rect(BackTextBlocks[i].DesiredSize));
BackTextBlocks[i].Margin = new Thickness(i * BackTextBlocks[i].ActualWidth, 0, 0, 0);
}
It is normal to display Chinese and Japanese characters like this:
but once English or other symbols are displayed, all the characters will be stacked together like this:
The full effect should look like this:
CodePudding user response:
You should not manually create TextBlock
elements. Better focus on the data and let the framework create the TextBlock
elements for you by defining a corresponding DataTemplate
(