Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
755
Change TextBox background color
posted

Hi all 

I am using the thememanager as follow:  

using Infragistics.Themes;
using Infragistics.Windows.Ribbon;

namespace SapQmWp
{
  /// <summary>
  ///   Interaction logic for MainWindow.xaml
  /// </summary>
  public partial class MainWindow : XamRibbonWindow
  {
    public MainWindow()
    {
      InitializeComponent();
      ThemeManager.ApplicationTheme = new Office2013Theme();
    }
  }
}

My question is, how can I change Textbox Background color with style? 

Thanks

Parents
  • 755
    Offline posted

    I've tried to follow:

    I created two files

    AzureTextBoxTheme.cs

    public class AzureTextBoxTheme : ThemeBase
      {

        protected override void ConfigureControlMappings()
        {
          // Get the full name of the assembly where the theme's resource dictionaries are placed
          string assemblyFullName = Assembly.GetExecutingAssembly().FullName;

          Mappings.Add("System.Windows.Controls.TextBox",
                   BuildLocationString(assemblyFullName, @"\AzureTextBoxTheme.xaml"));
        }

      }
    }

    AzureTextBoxTheme.xaml

    <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                        xmlns:local="clr-namespace:SapQmWp.Themes">

      <Style TargetType="{x:Type TextBox}">
        <Setter Property="Background" Value="BlanchedAlmond"/>
      </Style>
        
    </ResourceDictionary>

    And in the MainWindow.cs:

    public partial class MainWindow : XamRibbonWindow
      {
        public MainWindow()
        {
          InitializeComponent();
          ThemeManager.RegisterControl(typeof(TextBox));
          ThemeManager.ApplicationTheme = new Office2013Theme();
          
        }
      }

    And in the xaml file, where I need to change the theme:

              <ig:ThemeManager.Theme>
                <themes:AzureTextBoxTheme />
              </ig:ThemeManager.Theme>
              <TextBox Grid.Column="0" Margin="{StaticResource MarginTen}" IsReadOnly="True" IsHitTestVisible="False"
                       Text="{Binding Order}" /> 

    But I've got an exception:

    {"Cannot locate resource 'azuretextboxtheme.xaml'."} 

Reply Children