Right align WPF window title - c#

I'm currently creating a WPF Exception Window, much in the style of the MessageBox (static show methods). In attempting to Style it similarly, I have created an ExceptionWindowOptions enum which contains the value, RightAlign.
When the RightAlign flag is tagged in the MessageBox class, the window title is aligned to the right (next to the control box (minimize, max, close)), so i'm attempting to emulate this behaviour.
I have investigated as much as possible and I cannot find a WPF solution.
I am familiar with interop with native methods as I am using GetWindowLong and SetWindowLong for the RtlReading option, but I haven't managed to find anything to change the location of the window title.
Any help is appreciated.

Take a look on FluidKit library from Pavan Podila. Particularly, you may be interested in GlassWindow. The main idea here is that you override window style from scratch. Sure, this requires you to customize style for different themes, but at least it's a solution, if you don't find anything else.

I believe that you want to set Window.FlowDirection. That will set it for all content in the window however, including buttons, text boxes, etc, so if you ONLY want to make the title bar RTL, you could then have the window contain a panel which would reset it to LTR (or whatever).
Ack- on testing this, maybe not. It looks like it RTL's ALL of the title bar, including the control box and the icon!

Related

How to make message entry/list/view in C#

He I am a beginner to C# and I am working on a reaction manager plug-in for some bigger project. (Yes I am a intern)
Now I just can't find a way to create a view similar to this:
My full design:
How to realize this design? I cant find any default templates in the devexpress which are suitable for this. I come from php and in php I can use html. I am a beginner to C# and I don't have any clue on how t do this. Do I have to use canvas to literally draw this? OR is there a standard template I can use for this purpose.
You have many comment boxes that contain the same layout - a label comment text, author name, date, etc. There is no control that lays things out like that, you will have to make your own custom control (Project->Add User Control). This control will be a composite control - ie made up of other controls. Probably a label for each text field (comment, author, date, etc) laid out in the right places. Maybe call it CommentBox or something.
Then in the main form you now have available CommentBox controls which you can add to the form. Create a panel to put them in so you have many CommentBox controls in the panel, one for each comment (or maybe add them at runtime).
Now in WPF it's slightly easier because there is a StackPanel control that you can simply add controls to and it automatically arranges them vertically one beneath another in a stacked list. In fact your use case is exactly fitting what a StackPanel is for.
In WinForms there is no StackPanel, but you can use a normal Panel control*. It's just you'll have to position the CommentBox controls manually one beneath another. You will also need to set the AutoScroll property to true to turn on the vertical scroll bar if the content doesn't fit the view.
*or there's apparently an alternative How can I get a StackPanel-like layout in WinForms

How to make something similar to Visual C# 2008 properties window?

What interests me is everything below the bar with buttons that determine how the properties are displayed. All I can figure out is there is a splitter and a status strip.
What I'm after is how there are 2 sections which I want to add the titles Property and Value, the sections can be resized with a splitter (I assume a splitter is used in this case), each property can be selected and the corresponding description appears on the status strip, and each value can either be text or a dropdown box.
The coding part I can probably do by myself, what I need to know is what controls the window is made up of and how it's put together.
You are referring to the PropertyGrid control. It's in the ToolBox.
See Getting the Most Out of the .NET Framework PropertyGrid Control
This is the PropertyGrid, and can be used directly. There is no need to reinvent the wheel here...

What would be the best course of action for display different form in a single Winform?

Here's a screenshot of my application:
Basically, depending on what option is selected I'd like to show another 'content' which can be a buttons, or forms or whatever.
What would be the best choice for this? Using MDI? I'm really new to this type of thing.
This scenario lends itself well to tab pages, as you'd find on a TabControl.
However, since you already have a mechanism for switching between the content, you might prefer to create a series of Panels whose Dock property is set to DockStyle.Fill. When the user clicks the appropriate heading, you simply need to show the appropriate panel and call BringToFront() on it. This is essentially what the tab control does internally, anyway.
Don't forget to use SuspendLayout() and ResumeLayout() appropriately to reduce flicker, which can be a huge problem in WinForms applications, especially when there are lots of controls.
You can position a TabControl where the buttons are not visible and control it from your buttons.

How to design the UI for settings according to different options in C# WinForm?

This is a .NET winform application question.
I come to this design from time to time. A simple form. On top of the form you have a list of options to select. According to different option chosen, the body of the form displays a unique panel of setting detail.
How to design this UI in Visual Studio neatly? I have two ideas. First idea is to have many panels, each panel contains setting controls. In runtime, hide all panels but the one according to the selection of option. In this solution, it is hard to organize the controls of the form in VS designer. You need to set the form big to hold all the panels. Panels are put one next to each other. There are many runtime loading code to write. For example, when loading the form, you need to hide panels, reset the form size. When you pick an option, you need to relocate the panels and show/hide them. Tedious!
Second idea is to use TabControl. TabControl is good because the tabs are well organized for you. You don't need to relocate panels and resize the form. All you need to do in runtime is to select the right tab according to options. One thing, you need to hide parts of the TabControl from user because after all it is not a real TabControl. Hiding the tab buttons of the TabControl is not hard but I find that after that there is always a big gap between the tab area and the following part on the form.
Dose anyone have a decent way of designing the UI? Maybe not using panels or TabControls but some smarter way? If TabControl is used most of the time, how to hide and show the tab parts of the TabControl and how to set the margin and border size of the TabControl so no big gap exists? Many thanks to any answer and suggestion.
When I need to do this, I put each group of controls in its own UserControl, and then I can use something else to switch between them. See, for example, Implementing a paged Options dialog on my blog.
I suggest you create UserControls for each of your "setting details" and when the user selects an option you load the accordant UserControl. You might have to adjust the forms size, but therefore you can easily manage all the "setting details" in your IDE.
Using user control is a good way to solve your problem. But you need set them probably in panels and play with properties "Visible" and "Dock".
You don't need to Dock them at "Fill" in design mode. You can set this property à runtime or when needed.
Hope this help.
Sounds like you need some design pattern.
Why not create a UI factory that returns your UI objects as needed/required?

Winforms Creating Dropdown style panel

I am attempting to create my own custom Autocomplete style dropdown control in c# .net2.0. For speed of development I have built my control as a UserControl but have hit on an issue of doing it this way.
When the custom drawn dropdown gets drawn I have to resize the UserControl area to be able to display the list of options.
Ideally I want to be able to mimic the drodpown list behaviour in that the list of options is drawn 'floating' and is not constrained by the UserControls height and width (nor even the parent forms boundaries). A tooltip is another example of the unconstrained 'floating' that I desire.
The only way I can think of achieving this is to create on the fly a new form with no border or title bar and display this when the popup is required.
Is there a better (but also quick) way of doing this?
TIA
You would need to use a Form or NativeWindow to allow the control to float correctly. To make a form follow the control is easy enough but it is more difficult to implement and handle all of the focusing/hiding issues especially if you need seamless tabbing/key navigation.
You can try creating a control that is based off the ToolStrip Drop Down Button control. I believe that this control has the functionality that you are looking for. I found this reference for creating controls based off the ToolStrip, you might try starting with this.
http://blogs.msdn.com/jfoscoding/attachment/1335869.ashx

Categories

Resources