the title isn't really meaningfull... sorry for this.I'll try to explain my issue.
I have a bigger project in which i'm trying to implement a new WPF window which contains some custom controls. Going deeper this window should looks like, let's say, a calculator. This calculators has many keys buttons which are "custom controls" inherited from Controls, and their style are defined in Generic.xaml.
When i try to debug it, the custom controls (the key buttons) don't appear into the calculator window.
I think it's due to something wrong with the Generic.xaml file.
Can someone give me a hint ???
Thanks in advance
Paolo
A couple of suggestions:
download Snoop (it's free), it examines your Visual tree at run time and helps to see if controls are there, if the style making them invisible, etc.
remove the styles, run your project - do controls appear? then it's your styles!
do you have nameless/key-less styles that target buttons, other simple/out-of-the-box control? Then remove them too, if they are the ones affecting your controls, then consider changing them, or applying styles to your controls so they stop inheriting from those defaults.
I've searched a lot on the net and finally i've got the solution following the answer of this discussion wpf-resource-not-loading-from-generic. The clue is to add into the AssemblyInfo.cs these lines of code:
[assembly: ThemeInfo(
ResourceDictionaryLocation.None,
//where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly
//where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
Maybe this could be useful for someone in the future... :-)
Regards,
Paolo
Related
I started with MahApps and would like to know how to browse MahApps resources in general similar to Object catalog in Visual Studio. Like I am able to read all available Icons in the the icons.xaml in resource folder, I would like to be able to do so, for any DynamicResource such as AccentColorBrush.
If this is not possible, how am I supposed to know about my possibilities and the capabilities of MahApps since XAML does not know suggestions?
Take a look here: https://mahapps.com/guides/styles.html
Under the Creating Custom Accents and Themes chapter (about the end of the page), you can see all possible x:Key of colors and brushes according with the selected theme in App.xaml resources.
I'm developing a WPF application that uses the Fluent Ribbon Control Suite and i'd like to use its 'themes' in the rest of the application.
Specifically, when you choose to use the Blue theme
<ResourceDictionary Source="pack://application:,,,/Fluent;Component/Themes/Office2010/Blue.xaml" />
I would like to use some of the colours inside that file, to style other interface elements (buttons, popups etc).
Any idea how I might do this?
You can try this, but it's not ideal…
Downloaded the Source Code from here and open it up in Blend.
Using the Resources tab, browse the different ResourceDictionary file (ColorsBlue.xaml, Button.xaml etc.)
Make a note of the resource keys for the resources you want.
In your original application add the styles/colours etc you want.
Now whenever you change the theme (Blue/Black/Silver etc) it will automatically change the background colour of your controls!
Hope that helps.
I've just begun dabbling in putting together a set of controls as assemblies and I'm working on default styling. What I currently have is a UserControl in a project (thanks Reed!) and I'm able to bring that into another project via reference. I plan to add more controls over time to build something of an SDK.
I currently have some hooks that look for resources in the hosting application which either apply the resources to their respective properties, or style out the control via hard coded defaults.
Is it possible to set up resource dictionaries within the project containing the UserControls so they can use those references as the default, instead of hard coding? If so, how do I target them?
(I have a ResourceDictionary set up within the same project as the controls: Resources>Dictionaries>Colors.xaml)
Thanks in advance!
E
You should really look at creating custom templated controls in library rather than derivatives of UserControls. This will allow projects that reference your library to specify an alternative default style for you controls in the same way as we can for the controls in Microsofts own SDK.
The Creating a New Control by Creating a ControlTemplate topic on MSDN is good starter.
I think this is a better explanation, but i'm trying on a desktop application and i got the same problem.
XamlParseException: Failed to create a 'System.Type' from the text 'local:CustomerEntity'
If I'm undestanding correctly you want to create the file "generic.xaml" in the folder "Themes". However, I don't believe automatic styling works with UserControl only with Control. Generally if you trying to make a control that can be stylized and retemplated you want to inherit from Control and not UserControl.
At the moment I'm using Silverlight RadControls from Telerik. In my site I've implemented the RadUpload control. Because the control is not styled the way I want, I'm restyling it for my site. The way I'm doing this is as follows: Right click on xRadUpload > Edit Template > Edit a Copy. After doing this I'm able to style almost everything, except for one thing.
During runtime of the Silverlight application, the xRadUpload enables users to upload files. Those files that are selected using the browse button, show up in the application in several bars. I want to restyle those specific bars.
The problem is, I can't find those bars using Expression Blend.
I've already looked at the Telerik help documentation. It says that if you want to restyle the control you need to edit the following control templates: RadUpload and UploadItem.
After reading this I think I need to edit UploadItem, but I cannot find it, while my application works correctly. Has anyone encountered this problem before, who can help me?
Looks like Telerik has listed the items that are required in the UploadItem control. If you want to get the control template you can open the Telerik dll in Reflector and in Reflector look in the Resources folder for the dll. You should see the generic.xaml in there and you can double click it to open the file. In that file you should see the control templates.
My problem is solved, for the solution go to http://www.telerik.com/community/forums/silverlight/upload/xradupload-styling-problem.aspx
I'm building custom control for my Silverlight 2 app. It's in one SL class project, and it contains two files:
MyControl class, inherited from Control, with few DepedencyProperties
themes/generic.xaml, with visual elements (ControlTemplate), states for VSM and transitions
I created whole xaml by hand, and it works, but want to use Blend2(SP1) for editing! When i open generic.xaml in Blend, and switch to Resources tab I don't have anything to edit.
For example, when I put that visual template and states definition to App.xaml (of my main SL project), I can access all elements and States through Resources and States tabs, and edit them visually.
Does Blend even support editing generic.xaml from SL2 class project?
What's the best practice for building custom controls? I don't want to my custom control depends on anything from main SL2 project, but want them to be skinnable, and be able to change skins (themes) dynamically.
You can edit this with Blend.
Open your controls project in Blend.
Open your generic.xaml
click the Resources tab
Expand generic.xaml
Double click the style resource you want to edit.
In the Objects and Timeline section, right click the Style and select "Edit Control Parts -> Edit Template"
Now you can edit the template in the generic.xaml. Sounds like you're already following best practices by having the parts and states. If you want the full blown best practices take a look at this detailed post on how to deal with design time extensibility. There you will find out how to do the Visual Studio and Blend design time stuff for Silverlight.
I recreated whole project, and suddenly can edit my generic.xaml from Resources. But can't add news stated in Blend, for that I must go to xaml.