2016-07-05 3 views
-1

InkCanvasでいくつかのインクストロークを描画して、ペンの色を変更したいと思っています。私は、CopyDefaultDrawingAttributesとUpdateDefaultDrawingAttributesを使って描いた追加のストロークの色を変更することができ、うまく動作します。しかし、StrokeContainerが既に存在するストロークの色を変更するにはどうすればよいですか?私は試しました:Windowsで既に描画されているInkStrokesの色を変更するには

 foreach (InkStroke stroke in inkCanvas.InkPresenter.StrokeContainer.GetStrokes()) 
     { 
      stroke.DrawingAttributes.Color = strokeColour; 
     }; 

このコードは例外なく実行されますが、stroke.DrawingAttributes.Colorは以前の色を表示します。

アイデア?あなたが直接、脳卒中のDrawingAttributesプロパティを設定することはできません

おかげで...

ロバート

+0

[ここの例]に示すように、DrawingAttributesプロパティを更新しようとしましたか(https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.input.inking.inkdrawingattributes .color.aspx)? – Clemens

答えて

4

。ストロークのInkDrawingAttributesのコピーを作成し、そのInkDrawingAttributesオブジェクトに必要な値を設定してから、新しいInkDrawingAttributesをストロークのDrawingAttributesに割り当てる必要があります。

ですから、このような例のコードができます。詳細については、あなたがInkStroke.DrawingAttributes | drawingAttributes propertyを参照することができ

foreach (InkStroke stroke in inkCanvas.InkPresenter.StrokeContainer.GetStrokes()) 
{ 
    //stroke.DrawingAttributes.Color = Windows.UI.Colors.Yellow; 
    InkDrawingAttributes drawingAttributes = new InkDrawingAttributes(); 
    drawingAttributes.Color = Windows.UI.Colors.Yellow; 
    stroke.DrawingAttributes = drawingAttributes; 
} 

+0

ありがとうグレース - それは働いた。 – Robert

+0

@Robert、偉大なので、それはあなたの質問のための受け入れられた答えですか? :) –

関連する問題