Silverlight 4.0 如何获得Silverlight 4 RichTextBox的工具栏?

Silverlight 4.0 如何获得Silverlight 4 RichTextBox的工具栏?,silverlight-4.0,richtextbox,Silverlight 4.0,Richtextbox,我把RichTextBox放在我的Silverlight应用程序中。我必须创建自己的一组按钮才能使用它吗?我想为文本框设置一组标准的编辑按钮。不幸的是,它只是文本框,而不是像工具栏那样的一整套控件,这是商业WPF/Silverlight富文本框所能提供的 您可以将按钮绑定到格式代码: 要为Silverlight应用程序提供具有Mircosoft Office风格的格式化工具栏,请查看此控件可以完成的这是一个很好的解决方案 //Set Bold formatting to selected con

我把RichTextBox放在我的Silverlight应用程序中。我必须创建自己的一组按钮才能使用它吗?我想为文本框设置一组标准的编辑按钮。

不幸的是,它只是文本框,而不是像工具栏那样的一整套控件,这是商业WPF/Silverlight富文本框所能提供的

您可以将按钮绑定到格式代码:


要为Silverlight应用程序提供具有Mircosoft Office风格的格式化工具栏,请查看此控件可以完成的

这是一个很好的解决方案
//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);
}