0

XAML を使用して請求書フロー ドキュメントを作成しようとしています。

データバインディングを使用して ItemsControl を埋めていますが、これは正常に機能しますが、テキストが整列していません。以下を使用して:

String.Format("{0,-5}x   {1,-25}  €{2}", QT, "Desc", "Price")

それをテキストファイルに書き込むことは完全に機能しますが、それを List(Of String) に入れるたびに機能しません。ここで何が間違っていますか?

  Dim myCollection As New List(Of String)()

    Dim derpa As String
    derpa = String.Format("{0,-5}x   {1,-25}  €{2}", 4, "PYAH", "123")
    myCollection.Add(derpa)
    derpa = String.Format("{0,-5}x   {1,-25}  €{2}", 44, "PYAH2", "123")
    myCollection.Add(derpa)

    derpa = String.Format("{0,-5}x   {1,-25}  €{2}", 232, "PYAH2we", "33232")
    myCollection.Add(derpa)

    derpa = String.Format("{0,-5}x   {1,-25}  €{2}", 12, "asdasd", "213123")
    myCollection.Add(derpa)

    For Each item In myCollection
        derpaderpa.Text &= vbNewLine & item 'WPF Textblock

    Next

私が持っている現在のコードです。

4

1 に答える 1

0

The text doesn't line up because you are displaying it using a proportional font, not a fixed width font. With a proportional font, not all characters are the same width - spaces in particular are smaller than letters (and letters vary in size). The text editor appears aligned because it is using a fixed width font where all the characters are the same size. If you were to open the text file in MS Word you will see it not line up.

You could change the font in our ItemsControl to a fixed width font (e.g. Lucidia Console). What you probably want is a ListView with an embedded GridView which will display each item of information as a separate column - which lines up the data.

于 2013-09-29T18:20:28.133 に答える