开发者

RichTextBox FormatBar in code behind

开发者 https://www.devze.com 2023-02-02 11:56 出处:网络
Im looking at the codeplex WPF extended RTB and id like to perform the following in code behind: <RichTextBox>

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

精彩评论

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

关注公众号