How do I set the theme for child controls with Infragistics? - wpf

I'm using the Infragistics WPF controls in a new project, and I'd like to take advantage of their themes support. I'm able to change the theme of my window (and toolbars) via the OnThemeChanged event, but I can't figure out how to change the theme of child controls (such as the XamDockManager), as they're added at runtime.
I'm new to WPF and Infragistics controls so any clarification is appreciated.

I discovered the answer.
You need to set the control's Theme property to Theme.CurrentTheme. This will cause the controls to automatically pick up the new theme via their internal OnThemeChanged events.
This is the code I used, simplified a bit for this answer:
<igDock:ContentPane xmlns:igTheme="clr-namespace:Infragistics.Windows.Themes;assembly=Infragistics3.Wpf.v9.1">
// other stuff
...
<igDock:XamDockManager "Theme="igTheme:ThemeManager.CurrentTheme" />
</igDock:ContentPane>

Related

How to change windows style with MaterialDesign in wpf

I use MaterialDesign for style controls in wpf add.
I change all controls use MaterialDesign theme. I want to change windows style(WindowTitle, close,min,max button).
How to change this?
For this purpose you need to set Window Style (Border settings) = None and need to set user controls manually and apply code as per your requirement.
Or you can built your own custom control for this.

Global winforms styling

Are there global styles in Winforms as there are in WPF?
I'd like to be able to, for example, set ForeColor to be used by all the labels that exist within the app. Is there any solution, or do I have to do the changes manually for all the controls separately?
Most controls will inherit the font from their parent - so try setting the font styles you want on the window.

Is there a way to check what Style is setting a property's value for a control?

Just wondering if there is any tool to see what Style is setting a property value for a control. In our application, all the RadComboBoxes have IsEditable property set to true. There is some DLL that we are using is causing this. I am guessing there is some Style without a Keyfor the RadComboBox that sets this.
In WPF Inspector, I can see that every RadComboBox control in our App has IsEditable set to True. And under the Resources section there are a bunch of resources that show up, and some of these are set inside some external DLLs that we include in our project.
I would like to know what particular Style is causing this, so that we can narrow down our problem.
I usually check who set the property on Telerik controls by using Snoop.
Pin the element with Control + Mouse hover. Then select exact element in visual tree, select the suspecting Style property and use Delve button to see properties of Style property, namely look for x:Key.
When you find the key (usually RadSometingStyle or Template), open the install directory of Telerik controls, browse to Themes foleder and search over the all xaml files there. You'll find the style definition there. Good luck... :)

How to make custom WPF ContentControl that supports drag-and-drop at design time?

I want to create custom WPF control that has a single "child" control inside. Subclassing ContentControl or UserControl works, but has one flaw: these controls don't work in designer mode.
By "don't work" I mean this scenario: suppose I have a Canvas with my custom control in it. I want to put, say, a Button inside my control. I drag it from the toolbox, and it appears inside my control. However, XAML view shows that the new button actually belongs to Canvas, not to my control.
I can place it inside my control by manually editing XAML, but I want the designer to work too.
Interestingly, when I subclass Canvas, Grid or Panel, designer works as expected. However, these controls have many children, which is not what I need.
How can I make a single-child control that works in designer?
how about inheriting from Border? that way you could spare yourself the hassle with Designer Extensibility
I had the same problem with a content control I am writing and found an easy solution on this
StackOverflow thread.
Just implement the HitTestCore method:
protected override System.Windows.Media.HitTestResult HitTestCore(System.Windows.Media.PointHitTestParameters hitTestParameters)
{
return new PointHitTestResult(this, hitTestParameters.HitPoint);
}
I also had a similar question here.
But after digging and digging it seams that the real answer is "NO", there isn't any official way to support dragging controls straight into a custom Content-Control at Design-Time, even implementing 'HitTestCore' as Stephan's answer suggests, does not enable drag&drop at design-time for ContentControl.
For such purposes you should consider inheriting from either Grid or Panel (to allow multiple child controls), or Border (to allow single child).

How to find out which style(s) is applied to the control?

I have a huge XAML theme with multiple control templates and styles. I need to find out which styles from this list are being applied to which of my controls. I see that the style of my control has changed, but I can't find the source template/style for that change. For example, I have a Grid and I see that the background has changed, but I can't find the the templates/styles that have that Grid as its TargetType with any of that Grid's parameters.
Use the Snoop tool that can show you all your layout hierarchy and if element's attribute was set locally or inherited.

Resources