How to programmatically add a RibbonTab to WPF Ribbon (October 2010 release)? - c#

Does anybody know a way to programatically add a RibbonTab to a Mircosoft WPF Ribbon? I can't find an example or at least a property to use in neither documentation nor Ribbon's intellisense.
I found many entries all over the web suggesting something like: ribbon.Tabs.Add(...)
Unfortunately "Tabs" doesn't exist in the Ribbon class at all?! Was there an API change I can't find anything about or what's the trick?

The Microsoft WPF Ribbon inherits from Selector, which inherits from ItemsControl. With that in mind, to add a tab programmatically, you would use the Items property to add the new RibbonTab object.
For example,
Ribbon.Items.Add(new RibbonTab())

I haven't used the Microsoft WPF Ribbon much so I'm afraid I don't know, but I can however recommend the Microsoft Fluent Ribbon; I've had a lot more success implementing it, and found it significantly more flexible and intuitive...it's on the codeplex site if it's something you're interested in (presuming you haven't gotten too deep using the MS WPF Ribbon) - fluent.codeplex.com
Hope it helps,
Aj

Related

Is it possible to read data from Pane control type?

I've started using FlaUI for Automating my thick client .net application. The application is Windows Form based. The start was good and Login Form was identified and I could Login, but after that came the dead end and I found that almost everything in the application is developed as Pane control type.
So, there is grid, table etc. but they all just appear as Pane type when I see the object hierarchy using Inspect.exe or FLAUInspect tools. And nothing really appears in thier property, so it seems that nothing could be read. But before giving up I just wanted to check with experienced audience on this forum if there is really any way to get the data from Pane objects.
Please suggest if there is any way, even that means using other libraries like UIAutomation, TestStack.White, etc.
UPDATE: I now understand little more about this. So, the objects that are there in the pane are developed in syncfusion and devexpress. Is it possible to identify objects developed in syncfusion and devexpress using FlaUI or UIAutomation or TestStack.White, etc ?
I don't know if you have already tried the following steps. Have you add automationId's to your objects in xaml code with:
AutomationProperties.AutomationId="AnyID"
In the testcode, first initialize the main window of the application.
MainWindow = fApplication.GetMainWindow(fAutomation, null)?.AsWindow()
After that you can find your objects by the automationId's, like:
MainWindow .FindFirstDescendant(cf => cf.ByAutomationId(AnyID))
I did it this way, and don't have to know the hierarchy of my application. Maybe this will work?
Most UI Frameworks nowadays fully support UI Automation. So first make sure that you have a recent version of your framework (syncfusion, devexpress). In addition, some frameworks provide settings to enable UI Automation. Like for devexpress, you need to set
ClearAutomationEventsHelper.IsEnabled = false;
at the start of your application to test so it exposes way more things (like tabs) to FlaUI.

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

Create a list like the outlook 2010 inbox

I want to create a control that lists items, uses a collection of text and images in each item, can be scrolled though, titles given if re-ordered and can be selected.
The best example of this would be Microsoft Outlook 2010 inbox view with right reading pane.
I was hoping there would be something in the toolbox I could re-arrange to fit by needs? or would I have to build something myself? which would be a good challenge, but as I've not done this before I would like to avoid if I can.
There is no .Net FW control out of the box for you. Either look for open source control / build on your own. FYI: I know this can be easily done in WPF world though.
also check out TreeView and Custom TreeView for basic starters..
It would be easy to re-create if you didn't need it to be ordered. For an off the shelf solution that you may be able to customize to your liking you should check out the DataTables plugin for jQuery. http://datatables.net/

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