2010-04-19 35 views

回答

4

不幸的是,它只是文本框而不是整套控件,就像工具欄一樣,這是您使用商業WPF/Silverlight富文本框獲得的東西。

你配合你的按鈕高達格式代碼as shown here

//Set Bold formatting to selected content 
private void BtnBold_Click(object sender, RoutedEventArgs e) 
{ 
    object o = MyRTB.Selection.GetPropertyValue(TextElement.FontWeightProperty); 
    if (o.ToString() != "Bold") 
     MyRTB.Selection.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold); 


} 
//<SnippetItalic> 
//Set Italic formatting to selected content 
private void BtnItalic_Click(object sender, RoutedEventArgs e) 
{ 
    object o = MyRTB.Selection.GetPropertyValue(TextElement.FontWeightProperty); 
    if (o.ToString() != "Italic") 
     MyRTB.Selection.ApplyPropertyValue(TextElement.FontStyleProperty, FontStyles.Italic); 


} 

//Set Underline formatting to selected content 
private void BtnUnderline_Click(object sender, RoutedEventArgs e) 
{ 
    object o = MyRTB.Selection.GetPropertyValue(TextElement.FontWeightProperty); 
    if (o.ToString() != "Underline") 
     MyRTB.Selection.ApplyPropertyValue(TextElement.TextDecorationsProperty, TextDecorations.Underline); 
} 
+0

這是很好的解決方案,可以完成這個控制http://wintoolbar.codeplex.com/ – ahmedsafan86 2012-11-03 17:27:59