开发者

RichTextBox FormatBar in code behind

Im looking at the codeplex WPF extended RTB and id like to perform the following in code behind:

<RichTextBox>
   <toolkit:RichTextBoxFormatBarManager.FormatBar>
    开发者_Python百科   <toolkit:RichTextBoxFormatBar />
   </toolkit:RichTextBoxFormatBarManager.FormatBar>
</RichTextBox>

Im having brain drain, I have the following in my code behind but cant wire it up!

        Microsoft.Windows.Controls.RichTextBox rtb_wording = new Microsoft.Windows.Controls.RichTextBox();// USE extended RTB
        Microsoft.Windows.Controls.RichTextBoxFormatBarManager manager = new RichTextBoxFormatBarManager();
        Microsoft.Windows.Controls.RichTextBoxFormatBar formatBar = new Microsoft.Windows.Controls.RichTextBoxFormatBar();

Any help really appreciated


You shouldn't create an object of type RichTextBoxFormatBarManager. Instead, use a static method of this class like I wrote below. Note that "myCanvas" is the name of the grid/canvas container. Change it to whatever name you have for your container.

        Microsoft.Windows.Controls.RichTextBox rtb_wording = new Microsoft.Windows.Controls.RichTextBox();        
        Microsoft.Windows.Controls.RichTextBoxFormatBar formatBar = new Microsoft.Windows.Controls.RichTextBoxFormatBar();
        Microsoft.Windows.Controls.RichTextBoxFormatBarManager.SetFormatBar(rtb_wording,formatBar);

        rtb_wording.Width = 400;
        rtb_wording.Height = 200;

        myCanvas.Children.Add(rtb_wording);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜