2015-07-21 51 views
0

我在將紋理應用到我的C#WPF應用程序中的文本時出現問題。 我使用了Google,但找不到任何有用的東西。我應該使用WPF控件嗎?或者有沒有一個類在文本上應用紋理?將紋理應用到文本並保存c#wpf

+0

正是你想舉一些例子說明什麼 –

回答

0

有關TextBox.Text塗敷紋理,你可以爲你的TextBox.Foreground這樣定義ImageBrush

<Window.Resources> 
    <ImageBrush ImageSource="C:\...\texture.bmp" x:Key="TextureBrush" /> 
    <Style TargetType="TextBox"> 
     <Setter Property="Foreground" Value="{StaticResource TextureBrush}"/> 
    </Style> 
</Window.Resources> 
<Grid> 
    <TextBox Text="your text"/> 
</Grid> 
+0

非常感謝你對你幫助..你能不能也請協助改變文本在同一個文本框中的筆畫? –

+0

是否改變'FontWeight'而不是筆畫(例如'')會爲您做些什麼? –

+0

@amaidhassanniazi設置TextBlock或TextBox的Foreground屬性不會繪製輪廓。爲了做到這一點,你必須創建一個FormattedText對象並使用[BuildGeometry](https://msdn.microsoft.com/en-us/library/system.windows.media.formattedtext.buildgeometry(v = vs .100).aspx)方法。然後,您將使用幾何作爲Path控件的Data屬性,您還可以在其中設置Fill和Stroke屬性。 – Clemens