User controls vs Custom Controls Silverliht - silverlight

For developing a dashboard which will have many different widgets available, graphs, grids, etc, is a user control the best thing to use or a custom control?
I am a bit confused about the best situations to use each of them in
This relates to Silverlight 5
Paul

The key difference between user controls and custom controls is that custom controls can be re-templated, i.e. you can completely change their visuals by supplying a different template. If you do not need to do this in your application, I would recommend using user-controls as a simple alternative.
I have written a blog post about how to create them here:
A Simple Pattern for Creating Re-useable UserControls in WPF / Silverlight

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.

WPF Nested User Controls and MVVM (esp. Caliburn.Micro

I’m taking a lot of worry selecting an MVVM framework to convert to. One of the major considerations is support for User Controls and nested user controls as my main page today has a user control that contains nested user controls.
The author of Catel highlights lack of support for nested user contorls as a major disadvantage of other platforms (inc. Caliburn.Micro)
So my question is: Doesn't Caliburn.Micro support nested user controls?
Caliburn.Micro doesn't place any restrictions on the types of mechanisms you use for developing your user interface. It isn't a requirement to use Caliburn.Micro's conventions, you can still be explicit with your bindings when required.
If you are using user controls to reuse user interface code during view composition, then Caliburn.Micro provides an alternative technique for this too, using view model properties and ContentControls.
See here for an example.

ObserverableCollection UI pattern in WinForms

In many ways I think of using the MVC pattern in WinForms, but I'd like to know if it's possible to bind controls with objects using the ObservableCollection type? If it's purely for WPF, what other alternatives are out there?
To put it into perspective, we're building a system which has business logic that I'd like to control the UI with, instead of making customizations for each requirement or workflow on the UI itself. We have around a few hundred potential forms which I'd like to start designing with the pattern in mind.
We're also building web interfaces for most of the processes, but in reality they're just watered-down versions of the Forms. If I can use the same framework which I can just bind to on the web form that would be awesome.
Thanks
What ObservableCollection does is that it implements INotifyPropertyChange and each control in WPF has the possibility to listen for it's bound data to raise the event from INotifyPropertyChange. You can read more here about why you can't use ObservableCollection they way you want to in WinForms.
Another way is to use the Model-View-Presenter pattern:
This pattern can also be used in ASP.NET.
There's an MSDN Magazine Article on: "Better Web Forms with the MVP Pattern" that I think you should look into. And here is an introduction to how you use MVP-pattern in asp.net.

Visual Studios Controls

Is there a way to download more controls or anything, because I have seen a few things in other programs I don't think I've seen in the toolbox. Can you download new ones, or did the company somehow custom make a control? If it was custom made, are there any tutorials I can take a look at that tell how to make your own?
Some companies make third party controls for Winforms - Telerik is one I know of.
Personally, I prefer to make my own controls based on the existing WinForms ones, as I have more control over them - this prevents my products from having bugs which just can't be fixed. I can also tweak the controls to do exactly what I need, rather than choosing a closest match. Building custom controls is relatively easy if you have the experience.
There is a basic tutorial on CodeProject which shows how to create a fancy Button. After that you should be able to figure out how to customize more complex controls.
Side-note:
While it's reasonably easy to develop custom controls in WinForms if you have the time to practice, WPF is a much better framework for building custom controls. WPF controls are designed specifically for customization, so there is a lot more flexibility.

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