RichTextBox FormatBar 在代码后面 [英] RichTextBox FormatBar in code behind

查看:25
本文介绍了RichTextBox FormatBar 在代码后面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看 codeplex WPF 扩展 RTB 和 id 喜欢在后面的代码中执行以下操作:

<工具包:RichTextBoxFormatBarManager.FormatBar><工具包:RichTextBoxFormatBar/></toolkit:RichTextBoxFormatBarManager.FormatBar></RichTextBox>

我的人才流失,我的代码后面有以下内容,但无法连接!

<块引用>

 Microsoft.Windows.Controls.RichTextBox rtb_wording = new Microsoft.Windows.Controls.RichTextBox();//使用扩展 RTBMicrosoft.Windows.Controls.RichTextBoxFormatBarManager manager = new RichTextBoxFormatBarManager();Microsoft.Windows.Controls.RichTextBoxFormatBar formatBar = new Microsoft.Windows.Controls.RichTextBoxFormatBar();

非常感谢任何帮助

解决方案

您不应创建 RichTextBoxFormatBarManager 类型的对象.相反,使用这个类的静态方法,就像我在下面写的那样.请注意,myCanvas"是网格/画布容器的名称.将其更改为您的容器的任何名称.

 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);

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

<RichTextBox>
   <toolkit:RichTextBoxFormatBarManager.FormatBar>
       <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);

这篇关于RichTextBox FormatBar 在代码后面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆