Controls from external library not appearing in Telerik project - wpf

I'm working on a project that uses Telerik WPF controls (in so called NoXaml mode) and I have a library with controls I would like to use. These are simple WPF UserControls without even any template and contain only standard WPF controls placed inside them (and some logic). All these controls used inside are covered by Telerik templates and work outside of these UserControls. The library works everywhere, except in this Telerik project, in which the controls just don't appear, they are blank. Even a simplest <TextBlock> inside such control is invisible. Drilling down with Snoop sometimes makes them magically appear.
I've read that Telerik projects need to define templates for any custom controls that you create in them, but I'd like the library to be in control of the look of these controls, so my question is:
Can I actually use a custom UserControl library in a Telerik project without having to write my own control templates for them? If so, how to do that? If not, any other simple workarounds?
Thanks.

Related

Which element to use to modularize WPF applications?

Lets say I have a search box, which is a stack panel containing a TextBox and a Button with an icon. For easier re-usability I would like to extract said search box into a separate file.
What would I use to wrap the searchbox? I have all the functionality as attached behaviors, so I don't need any code behind.
ItemsControl doesn't fit, because I don't want to display items, ContentControl does not, because I have no content...
Could you give me hints how to fragmentalize in XAML? The only examples I find are for ResourceDictionarys, but not everything is a Style.
User Control
User Controls provide a way to collect and combine different built-in controls together and package them into re-usable XAML. User controls are used in following scenarios:
If the control consists of existing controls, i.e., you can create a single control of multiple, already existing controls.
If the control doesn't need support for theming. User Controls do not support complex customization, control templates, and difficult to style.
If a developer prefers to write controls using the code-behind model where a view and then a direct code behind for event handlers.
You won't be sharing your control across applications.
Custom Controls
A custom control is a class which offers its own style and template which are normally defined in generic.xaml. Custom controls are used in the following scenarios:
If the control doesn't exist and you have to create it from scratch.
If you want to extend or add functionality to a preexisting control by adding an extra property or an extra functionality to fit your specific scenario.
If your controls need to support theming and styling.
If you want to share your control across applications.
source (including example and more)
What would I use to wrap the searchbox?
A UserControl: https://msdn.microsoft.com/en-us/library/system.windows.controls.usercontrol(v=vs.110).aspx
Creating a UserControl is a suitable model if you want to build your custom control by adding existing elements like for example StackPanels and TextBoxes to it.

Resource Dictionaries in a Silverlight Assembly?

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.

Custom Message Box in WPF - What project type?

I have a WPF Composite application and I want to create a customized messagebox, I wondered what project type I should use to create it?
A usercontrol
A WPF Application
A Class Library
I have to then be able to use this MessageBox in other places in my application.
I have to then be able to use this
MessageBox in other places in my
application.
Since you want to share and reuse the component, you should probably not use an application project; it is technically possible to reference an application project from another project, but it's not very idiomatic. So you want a library project instead. In Visual Studio, the Class Library, WPF Custom Control Library and WPF User Control project types are all library projects: the only difference is which system DLL references are set up for you, the initial files generated, and what VS puts on the Add Item menu.
So any of these three options will be fine, but my recommendation would be either WPF User Control Library or WPF Custom Control Library since that will:
automatically include references to
the WPF DLLs; and
set up the Add Item menu to make it easier for
you to add actual controls to the
library in future (since you are
bound to come up with some reusable
controls as well as your message
box, and you may as well stick them
in the same project).
I have implemented a WPF MessageBox fully customizable via standard WPF control templates:
http://blogs.microsoft.co.il/blogs/arik/archive/2011/05/26/a-customizable-wpf-messagebox.aspx
Features
The class WPFMessageBox has the exact same interface as the current WPF MessageBox class.
Implemented as a custom control, thus fully customizable via standard WPF control templates.
Has a default control template which looks like the standard MessageBox.
Supports all the common types of message boxes: Error, Warning, Question and Information.
Has the same “Beep” sounds as when opening a standard MessageBox.
Supports the same behavior when pressing the Escape button as the standard MessageBox.
Provides the same system menu as the standard MessageBox, including disabling the Close button when the message box is in Yes-No mode.
Handles right-aligned and right-to-left operating systems, same as the standard MessageBox.
Provides support for setting the owner window as a WinForms Form control.

WPF User control or Template? How would i create a Template using Blend?

How would i create a window template using Blend? My application will be sharing many pages with the same layout.
One of my major concerns is what will happen when i need to make a change to the template. Will this update all of the pages automatically? Should i just use a usercontrol and add it to everypage?
Stay away from UserControls, generally. Instead, you want to use ControlTemplates, and put them in Resource Dictionary files, which you can totally make with Blend.

What is the best practice for creating RE-USABLE control templates in Silverlight

What is the best practice for creating re-usable control templates.
For example. I want to start with the standard checkbox and modify its template for re-use accross multiple future projects.
I understand how to modify the template in Blend, but it always wants to save the template to App.xaml of the current project or to the parent control where I first placed the checkbox.
Ideally I would like some soft of ControlLibrary that contains all my custom controls AND custom templates (modified templates of existing controls)
-Jeff
Implicit Style Manager might be helpful.
The Silverlight controls team and others have been blogging a bit recently about ISM which allows alternative style sets to be applied across the board to standard controls. Try Jesse Liberty's blog or Mehdi Slaoui Andaloussi's blog
HTH
I don't think you can have a ControlTemplate as a separate entity, without it being attached to a Control. For your control library you can create custom controls that have the appropriate custom templates and reuse the controls.

Resources