2011-07-30 30 views
3

我一直在試用Ribbon控件並遇到了一個可能的錯誤(或者我可能做錯了事情)。如果我對一個RibbonTabRibbonTextBox,並設置在代碼中的IsEnabled後面,我只能將它設置爲false,但不是真正的。 RibbonTextBox仍然有待禁用。無法設置RibbonTextBox isEnable爲False

/* 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 

回答

5

Apperently,這是一個已知的問題

RibbonTextBox IsEnabled property is always false

可能的解決方法也是在那個鏈接給
更新:我嘗試此變通自己和它確實工作

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

我也試過這個解決方法,並且ih廣告問題。

在xaml中我沒有問題來設置和定義RibbonTextBox的一些屬性。我可以運行代碼,文本框顯示在屏幕上,但未啓用。

,如果我有我的MainWindow.xaml.cs內的解決辦法代碼我得到一個錯誤「的類型或命名空間名稱RibbonTextBox'找不到」。

  1. 在哪裏,我必須包括代碼(MainWindow.xaml.cs?)。

  2. 命名空間system.windows.controls.ribbon是未知的。哪個dll必須設置到引用中(在參考中找不到System.Windows.Controls.Ribbon)?我認爲我必須使用這個命名空間來獲得ribbontextbox。我使用VS2010 express c#。