2017-12-07 5 views
0

私はpowershellに問題があり、TextBlockのテキストの一部をスタイリングしています。Powershell:RunspaceのTextBlock - フォントスタイルのインラインを追加

テキストをランスペースウィンドウにプッシュする機能を使用し、その中にTextBlockが正常に動作します。

Function Update-Log { 
    Param (
     $Content, 
     $type = "Black" 
    ) 
    $syncHash.Window.Dispatcher.invoke(
     [action]{$syncHash.log_txt.Foreground = $type; $syncHash.log_txt.Inlines.Add($Content); }, 
     "Normal" 
    ) 
} 

でも、色の変更は問題なく動作します。しかし今、私は個々の言葉をと太字のにしたいと思います。私は実用的なアプローチを試みました:

Update-Log "Here is some <bold>bold</bold> text." 

残念ながら、これはうまくいきませんでした。この問題の解決策を見つけるのを手伝ってもらえますか?

答えて

0

あなたが大胆活用する必要があります:

Update-Log "Here is some <Bold>bold</Bold> text." 
+0

残念ながら解決しません:/ – user3257571

0

私は解決策が見つかりました:

$syncHash.TextBlockName.Dispatcher.invoke(
     [action]{ 
      $Run = New-Object System.Windows.Documents.Run 
      $Run.Text = $Content 
      $Run.FontWeight = $weight 
      $Run.TextDecorations = $decorations 
      $Run.FontStyle = $atyle 
      $syncHash.TextBlockName.Inlines.Add($Run) 
      }, 
     "Normal" 
    ) 
} 
関連する問題