Adding a textblock to a custom wpf control (piepiece control from codeplex) - c#

I'm currently building a Surface application where the main navigation is a circular menu. For each menu item I'm using a custom control that I found on codeproject.com:
http://www.codeproject.com/KB/WPF/PieChartDataBinding.aspx (PiePiece control)
The number of submenu items (which is also piepiece controls) comes from a database and thus dynamically loaded. What I can't figure out is how I add a textblock to this custom control to display the submenu item text. It needs to follow the PiePiece's RotationAngle property to line up correctly.
Anyone got a hot-fix for this? I was thinking about adding another dependencyproperty to the piepiece custom control, but that way I can't set the font-family, size etc (can I?)
Any input on this is greatly appreciated! Thanks!

Have you tried using an Adorners, without taking a really close look the PiePiece Control you're using this might solve your problem.
Hope that helps!

Related

How To Create Draggable and Drappable List Of Controls?

I have a ItemControl and i set ItemPanel Property to Horizontal StackPanel and I Bound it to ObservableCollection of Icons.Now I Wanna user be able to remove icons with drag drop them to out of ItemControl and also can change items positions with each other by drag and Drop.
(Look likes MacOSX DocBar).Can i do this with above controls ,if yes,please tell me how.if not,i appreciate to tell me i should use which controls and how
Thanks In Advance.
You should be able to with your own inherited version of the controls. Microsoft writes their controls in a way to allow for easy inheriting and overriding of behavior.
It should be similar to what's done here:
http://www.codeproject.com/Articles/7841/Drag-and-Drop-Treeview-control
You want to watch events like DragStart, and DragLeave, and when it's not over your control and drop is performed do your operation.
More information:
http://msdn.microsoft.com/en-us/library/za0zx9y0.aspx
Good luck.

C#: custom control vs native control

ALL,
I am trying to develop a C# Windows Forms application.
For that I needed to make a custom control that is derived from the GroupBox.
Now for the problem.
I have a form and on the form I put a grid box. On 1 cell I put a GroupBox and on another cell I put my custom control.
For both controls properties I put "ColumnSpan" to be 3 as grid has 3 columns.
The native control display itself properly, meaning it is stretched.
The custom control display itself incorrectly, meaning it is not stretched.
I checked and all properties in the properties inspector are the same.
What am I missing?
Thank you.
For some reason custom controls do not resize themselves. So all I had to do in the GUI designer is to resize the control.
Thank you for reading and hopefully it will help someone else.

Dynamic Windows Form Control Creation - General Question

I'm working with a GUI in PowerShell and trying to make the form such that, after the form is built, the user can interact with the part of the form (+/- button) to dynamically add a group of controls to the form underneath of the existing set.
As an example, there will be a combobox (drop-down) to select a parameter and then a text field to fill in the value for the selected parameter.
What I'm looking for is a way to dynamically add that group of controls to the form when the user clicks the plus button. My current attempts have failed. I've tried pinning the controls inside of a TableLayoutPanel and a Panel object but can't seem to get the items to appear in the first place and then appear in some semblence of order. Is there a GUI object that I can pin the controls to that will just auto-dump the next row of controls below the existing or do I have to figure out the calculations off of the docked parent and offset the Y-values?
Does anyone know a PowerShell accessible Windows form control that would support this type of additions?
One of my attempts is psoted here: .NET 4 (WinForms) Dynamic Form Control Creation in Powershell
Any help is greatly appreciated.
Maybe you could use FlowLayoutPanel. Here is the sample script for using FlowLayoutPanel in Powershell
It's not Winforms, but there is a new module up on Codeplex called ShowUI, which enables you to create WPF based UI's in PowerShell. Take a look at http://showui.codeplex.com. There is some examples up there on using Grid controls and automatic layouts, that I think could meet your needs if you are willing to jump into WPF.
Got the answer from a Microsoft PowerShell forum Moderator:
http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/b2c8abeb-3ae6-4936-9bef-a50a79fdff45/
it's the datagridview object that needs to be used.
Can't you simply build your form (for example with Sapiens free editor tool) with all the controls invisible, and then according to the user choice make them visible ?

Creating a reusable interface element in WPF

I'm developing a WPF application in C# and was thinking about implementing a custom UI element accross various windows.
I would like to have a minimized tray (only about 4px visible) that expands after clicking on an icon next to the tray. The expanded version would show all controls and would minimize when I click the icon again. I created a quick HTML concept to clarify things.
I know I could put a stackpanel and button in my application and making both of them move up when I click the button, but then I would need to duplicate the code a lot.
Though I'm experienced with C#, I'm fairly new to WPF interface development/templates, but I'm sure there has to be a way so I can use that UI element accross my application without needing to copy/paste a lot of lines of code in my form class file.
I hope someone can help me, or at least point me in the right direction.
There are three ways to customize your elements.
1 If you only need visual modifications you can use styles to change the appearance of the .net default controls. You can even override / extend the default templates.
2 If you want custom logic in a control you can create a custom control. The framework brings a lot of "primitives" to build upon. Examples are ContentControl or HeaderedContentControl. Say you want to build a custom expander control you can inherit your custom control from HeaderedContentControl which provides you with Header and Content properties and you just have to implement the toggling logic yourself.
CustomControls are a good choice if you want to build basic functionality which can be used throughout your application. They can be themed/styled depending on the use case, too (see 1).
3 If you want to compose different controls into one control you can create a UserControl. User controls are composed using XAML. Most top level controls are user controls driven by a view model.
Your case can be build using a Popup and ToggleButton or an Expander.
The decision depends on the desired behavior. If you want the opened panel to move following content down you need a expander. If you want a dropdown like functionality you need popup.
If you use a popup just bind the IsPopupOpen Property to IsChecked of the ToggleButton and set PopupStaysOpen = false to wire the button to your popup.
If you use an expander control you should create a style which can be applied to all equal expanders in your application to minimize the required XAML in each view.
How about using Expander Control?
There's a control called an Expander that is perfect for this. You'll have to style it to look like you want, however it has the functionality you want built-in.

How can I change the default Control template of a TabControl according to my choice

I am trying to develop a Customize TabControl in which I'll divide the Whole TabControl into three Parts:
1)Tab Header
2)Common Region(for all Tab) and
3)Tab Content region for specific Tab
Update:
Please provide your best answers or samples if you have then, any type of help will be appreciated.
Thanks in Advance
You can overwrite the TabControl Template to be anything you want, including making it have a static region that stays visible regardless of which tab is selected.
Within the Template, I normally use a panel with IsItemsHost=True to define where the "Tab" portion of the tab control will be displayed and <ContentPresenter ContentSource="SelectedContent" /> where I want the selected tab content to be displayed.
The TabControl.ItemTemplate can also be overwritten to further define your Tabs, and TabControl.ItemContainer can be overwritten to modify just the TabContent part of the TabControl.
Hmm ... I don't quite understand why one would do this, but if I were you I would implement this using WPF.
I would implement the tab header as a StackPanel filled with Buttons (their style obviously needs to be redone so that it looks like tabs). The content would be a rectangle containing a grid whose content changes on clicking a button. And that's pretty much it for the basic sceleton. I don't understand your Common Region. What is also nice is to add a little "X" inside each tab in order to close it. That can be done with buttons as well.
It might make sense to use Expression Blend to create such a control.
Best wishes,
Christian

Categories