无法将 RibbonTextBox isEnable 设置为 False

发布于 2024-11-27 11:19:40 字数 539 浏览 0 评论 0原文

我一直在尝试功能区控件并遇到可能的错误(或者我可能做错了什么)。如果我在 RibbonTab 上有一个 RibbonTextBox,并将 isEnabled 设置为 FalseTrueRibbonTextBox 仍处于禁用状态。

/* in my XAML */
<ribbon:RibbonTextBox x:Name="rtb" Label="Button1" />

/* in my code behind */
rtb.IsEnabled = false;  // RibbonTextBox is disabled and grayed out
... some other code ...
rtb.IsEnabled = true;   // RibbonTextBox remain disabled and grayed out

I have been trying out the Ribbon Controls and experienced a possible bug (or I am doing something wrong perhaps). If I have a RibbonTextBox on the RibbonTab, and setting the isEnabled to False or True in code behind, I can only set it to false but not the true. The RibbonTextBox remain to be disabled.

/* in my XAML */
<ribbon:RibbonTextBox x:Name="rtb" Label="Button1" />

/* in my code behind */
rtb.IsEnabled = false;  // RibbonTextBox is disabled and grayed out
... some other code ...
rtb.IsEnabled = true;   // RibbonTextBox remain disabled and grayed out

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

↘人皮目录ツ 2024-12-04 11:19:40

显然,这是一个已知问题

RibbonTextBox IsEnabled 属性始终为 false< /a>

该链接还给出了可能的解决方法
更新:我自己尝试了这个解决方法,它确实有效

public class FixedRibbonTextBox : RibbonTextBox
{
    protected override bool IsEnabledCore
    {
        get { return true; }
    }
}

Apperently, this is a known issue

RibbonTextBox IsEnabled property is always false

A possible workaround is also given at that link
Update: I tried this workaround myself and it does indeed work

public class FixedRibbonTextBox : RibbonTextBox
{
    protected override bool IsEnabledCore
    {
        get { return true; }
    }
}
蝶…霜飞 2024-12-04 11:19:40

我也尝试过这个解决方法,但遇到了问题。

在 xaml 中,我可以毫无问题地设置和定义 RibbonTextBox 的某些属性。我可以运行代码,文本框显示在屏幕上但未启用。

如果我在 MainWindow.xaml.cs 中包含解决方法代码,则会收到错误“找不到类型或命名空间名称“RibbonTextBox””。

  1. 我必须在哪里包含代码( MainWindow.xaml.cs ? )。

  2. 命名空间 system.windows.controls.ribbon 必须是未知的。设置为引用(在引用中找不到 System.Windows.Controls.Ribbon)?我想我必须使用此命名空间来获取 RibbonTextBox。我使用 VS2010 Express C#。

I have also tried this workaround and i had problems.

In xaml i have no problems to set and define some properties of a RibbonTextBox. I can run the code an the textbox is displayed on the screen but not enabled.

if i include the workaround-code inside my MainWindow.xaml.cs i get an error "The type or namespace name 'RibbonTextBox' could not be found'.

  1. Where i have to include the code ( MainWindow.xaml.cs ? ).

  2. The namespace system.windows.controls.ribbon is unknown. Which dll must be set into references ( cant find System.Windows.Controls.Ribbon in references)? I think i have to use this namespace to get ribbontextbox. I use VS2010 express c#.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文