How to find all WPF controls definition and usage examples? - c#

Where can I find a reference for definitions and examples of all WPF controls. I'm new to WPF and much confused with the usage of majority of controls (such as canvas, stackpanel, winformshost, wrappanel, dockpanel, contentconstrol.) In WinForms, we didn't have that many controls. Googled for wpf control definitions and usage, but found nothing.

Start here: Windows Presentation Foundation for general WPF information.
For info specifically on controls: Controls by Category
The msdn site is probably your first best option to find out about WPF.

MSDN Control Library is always a good start.
I also found this site useful when I began using WPF.

Please visit the link
http://wpftutorial.net/Layout.html
Here you will find the code samples as well as the explanation.

Related

Creating custom ListView from scratch in Blend

I already looked through the internet but could not find a tutorial that showed the creation of a ListView in Expression Blend. I do not want to modify existing ListViews that are part of Blend, as I have done that already.
I need a tutorial that shows the first steps of creating a custom ListView and, in my case, specifically states all the parts the ListView consists of.
A button for example, can be created in Blend by drawing a Rectangle, adding a ContentPresenter and converting that into a Button user control. I would like to do the same thing for a ListView.
I went through that post already but since it is about WinForms I could not draw any helpful conclusions.
I am thankful for links to similar posts, tutorials and even code snippets.
After a long night of further research I came across this answer. I installed the Windows SDK and there are files that contain the ControlTemplates for WPF Controls. Using them as a blueprint gives me the possibility of creating my own desired version of the ListView.

How to Use WPF Controls Inside an Excel Actions Pane?

There are several resources out there that explain how to add WinForms controls to Excel. See these two:
http://msdn.microsoft.com/en-us/library/vstudio/e3zbk0hz%28v=vs.100%29.aspx
http://www.clear-lines.com/blog/post/create-excel-2007-vsto-add-in-wpf-control.aspx
Both of them mention the more up-to-date option of using WPF controls (the one I need). Unfortunately, both resources are lacking the fundamental part. There is a missing link:
(1) The Microsoft site mentions some video -with the exact title that matches my requirement- but all videos in that web site have been removed, it seems.
(2) The Clear-Lines site contains an outstanding, step-by-step project but alas, when the critical part is mentioned, the author uses some facility (the "WPF Interoperability section of the Toolbox") that does not exist in VS-2010+
Based on the above screenshots, and other sites, I have come to the conclusion that the missing link, the connection between my WPF UserControl and its appearance in Excel is some ElementHost.
Addendum for #HighCore. See Toolbox below:
Esteemed Self:
Your problem is that you are trying to place a WPF Control inside another WPF Control.
You need to create an old-fashioned WinForm Control and next you use the Toolbox as depicted here:
Notice that the section ElementHost Tasks has been renamed WPF Interoperability but it is otherwise very much alive.
From MSDN Magazine:
http://msdn.microsoft.com/en-us/magazine/cc163292.aspx#S4
I'm not sure why you think there's a "missing link". The ElementHost is the standard way to host WPF content on winforms, and it's perfectly documented in the link above, and also here.
given any winforms container (such as a Form or Panel), simply do:
var elementHost = new ElementHost
{
Child = new YourWPFContentHere()
};
this.Controls.Add(elementHost);
make sure you add references to these assemblies:
PresentationCore
PresentationFramework
System.Xaml
WindowsBase
WindowsFormsIntegration

How to make custom form control in c#

I was trying to do something in visual studio the other day when I realized, if I could just make a form control to do it for me it would be allot easier, except I have no idea how to do that, I want the form control to have grids, each square having its own color property, if anyone knows how to make form controls, or even better knows how to make something like what I just described, I would be very happy :D
This MSDN article is a basic step by step outline of how you can write a customer control.
Unfortunatly MS has not figured out how to do avoid link rot -- so you may need to search creating custom winform controls to find this if you come in the future.
You are usually best servered by subclassing an existing control and customizing it.
You might also find some of the freely available winform control projects a gold-mine of useful info if you get serious about this.
However, it sounds likely what you should consider doing is creating a "User Control", this is usually simpler for a composite of few existing controls. This
article on the types of controls for winforms may be a useful overview for you.
Beyond that you really should use S/O if you are trying to resolve a specific problem you are having when you are coding. Google is a more appropriate tool for finding tutorials, etc.
1) Inside your project: Solution Explorer --> Right Click the .csproj --> Add UserControl
2) Drag and drop gridBox or any control you want into your custom control.
3) Check the ToolBox, your custom control should be located at the very first selection

What control should I use for this UI?

I'm relatively new to WPF, so could anyone give me some guidelines on how to build this UI (it's main panel of Paint on Windows)
I prefer code style over XAML (just for the learning purpose), so a general idea on what controls should be used would be more than enough, I can handle the detail of each element.
There are online templates. I think that you are searching for Ribbon Control Template.
Then, Codeproject has a great article about this.
You can check this msdn article, too.
In these links you have a lot of examples.
To use it you will create a new project with an online template, like in the image bellow (you see: it's selected WPF Ribbon Application:
That is a Ribbon control.
You can check this out: Introducing Microsoft Ribbon for WPF
Probably want to use the Ribbon Control? http://www.microsoft.com/en-us/download/details.aspx?id=11877
When I had the same question in my mind, I did an analysis of all ribbon controls and collected their links.
Here are they
http://fluent.codeplex.com/
http://wpf.codeplex.com/wikipage?title=WPF%20Ribbon%20Preview&ProjectName=wpf
http://www.microsoft.com/en-us/download/details.aspx?id=11877
Code Project Links:
http://www.codeproject.com/Articles/24062/A-Demonstration-for-WPF-Ribbon-Control-Library
http://www.codeproject.com/Articles/23199/WPF-C-Ribbon-Control-Library
http://www.codeproject.com/Articles/23343/A-Graphical-WPF-Ribbon-Control-Builder

Suggestions for a C# custom tabcontrol?

Has anybody got any suggestions for a custom tabcontrol implemented in C# and which adheres to these criteria:
Allows the tabs to be placed along the side of the control.
Tab text must read horizontally.
Allow custom colouring.
Open source or no cost.
I prefer not to get my hands dirty with ownerdrawing if a solution already exists.
You probably don't have a need for this anymore but anyone else who stumbles upon it might find it useful.
I found this tabcontrol on CodeProject it is also very easy to Draw your own tabs with it, they even give you a example on the site.
Y(et)A(nother)TabControl
A couple more tab controls.
TabStrip Control
TabStrips: A TabControl in the Visual Studio 2005 way!
The tab control in WPF fulfills all of your requirements. You can override the template and go to town on it.

Categories