positioning RightToLeft controls in canvas - wpf

i have a canvas that users can add some controls from toolbox to it, I have a PropertyGrid that binds to selected control in canvas.
My problems are listed below:
when one control is selected from canvas, some it's properties listed in PropertyGrid. When I change some of these properties (For example:FontFamily,FontSize,Foreground) the appearance of selected control is not changed but it's FontFamily changed properly,
some other properties work fine (for example:Width,Height,FlowDirection)
I save the properties of controls in a xml file, When I load the xml file and add controls to a cleared canvas according to xml data,
the positioning of RightToLeft controls is incorrect but LeftToRight controls aligned correctly, (the Left coordinate of RightToLeft controls aligned to Right coordinate of it) see below:
For LeftToRight Controls:
For RightToLeft Controls:

Related

right to left text in contextmenu

I can see all texts of contextmenu and its menuitems and submenuitems on right side, that is Right to Left.
cm.RightToLeft = RightToLeft.Yes;
this.ContextMenu = cm;
Now, I use cm.MenuItems[1].MenuItems[0].Enabled = false OR menuSubItem.Enabled = false. Now I see texts of menusubitems on left, that is Left to Right.
I want all text strings to be on right, that is Right to Left.
Setting a form or control's RightToLeft property to true reverses the
reading order of elements on a form, but it does not reverse the
layout to be right-to-left — that is, it does not cause mirroring.
You can create mirroring in code. For forms, you can set an extended
Windows style to cause mirroring. For most controls that require
mirroring, you can create a mirrored control by inheriting from the
base control and setting the same Windows extended style. You can
create mirrored versions of the following controls:
ListView Panel StatusBar TabControl TabPage ToolBar Treeview
Some controls are sealed, so you cannot derive a new control from them.
These include the ImageList and ProgressBar controls.
But there is a non-like thing. When you design a Form and put some
some controls on it, the appearance during runtime will be mirrored.
The control that you put it at the right of the form will be shown at
the left.
Source: http://www.codeproject.com/Articles/5071/Windows-Forms-and-Controls-with-Right-to-Left-Layo
Follow the source for guidelines.

wpf datagrid FrozenColumnCount and usercontrol with adorner

i have a DataGrid with FrozenColumnCount set to one and some DataTemplateColumns which contains a control which uses an adorner (simply lets say a TextBox with an Adorner which shows the Text "Unit" or somelike). If I use the HorizontalScrollbar the adorner lays before the fixed column. How can I solve this problem.
This is the nature of Adorners, they will always be on "top".
Anything placed in the adorner layer is rendered on top of the rest of
any styles you have set. In other words, adorners are always visually
on top and cannot be overridden using z-order.

FlowLayoutPanel AutoSize height not working

I'm working on a UserControl that consists of a bunch of ComboBoxes arranged horizontally across the top of the control in a flowlayoutpanel, and a datagridview directly below the flowlayoutpanel that takes up all remaining space on the control. I need to be able to hide all the dropdowns easily, so I have a SplitContainer with Orientation == Horizontal, with the flowlayoutpanel in SplitContainer.Panel1, and the datagridview in SplitContainer.Panel2.
The control hierarchy is as follows:
SplitContainer1
SplitContainer1.Panel1
FlowLayoutPanel1
ComboBox1
ComboBox2
ComboBox3
SplitContainer1.Panel2
DataGridView1
Since the flowlayoutpanel is oriented horizontally and horizontal space is limited, the flowlayoutpanel's WrapContents property is True, so that the dropdowns wrap down to the next row when the control is made too narrow to fit all the dropdowns in one row.
The problem I'm having is that when the flowlayoutpanel wraps its contents down onto the next row, its Height property does not change accordingly. The wrapped rows of the flowlayoutpanel are clipped, and don't force the splitcontainer panel to grow in height accordingly. I've tried to handle the FlowLayoutPanel.Resize event to grow and shrink the SPlitContainer.SplitterDistance property to accommodate the wrapped contents, but the FlowLayoutPanel.Height property does not change when contents are wrapped. I'm stumped. Is the FlowLayoutPanel broken? How can I resize the FlowLayoutPanel's parent container if FlowLayoutPanel.Height always remains the same, regardless of content wrapping?
Thanks
It seems like you're making this a little too complicated for what you need. You can use the built-in docking to accomplish what you want without using the SplitContainer. Set up your form like this instead:
FlowLayoutPanel1 (Autosizse = true, Dock = Top)
ComboBox1
ComboBox2
ComboBox3
DataGridView1 (Dock = Fill)
Then when you want to hide FlowLayoutPanel1 you can just toggle the Visible property to hide/show it.

WPF UserControl Designer Problem with Strech

I have a WPF UserControl (Foo.xaml) that should be displayed streched (VerticalAlignment="Stretch" HorizontalAlignment="Stretch") on a window.
If I don't specify Width/Height on the UserControl it will be displayed as intended at runtime. Unfortunately the VS WPF designer will not show the control correctly if I open Foo.xaml (size may be 0x0 depending on the child controls).
If I specify a size on the UserControl the designer will work correctly with Foo.xaml but then it won't strech at runtime.
How can I fix this so that it works at design and runtime?
It sounds like your UserControl is only useful if it is a certain minimum size. If so, set the MinWidth and MinHeight properties.
You can set the DesignWidth and DesignHeight properties on the UserControl to adjust the height and width of the control in the design view.
You can adjust those properties with the mouse by dragging the square rectangles that show up when you select the resize tool for the UserControl.

ItemTemplate vs ControlTemplate

I am confused with learning about WPF. I see ControlTemplate used to determine how each item in a listbox looks. Isn't that what the ItemTemplate is used for in listboxes? What is the difference?
A ControlTemplate let's you change the look&feel of existing controls, for example, make a normal everyday button look like Vista's taskbar shiny glass buttons or make a tab control look like the new Office 2007 ribbon.
The idea is that the control contains only the behavior and the ControlTemplate contains the look&feel - so a button is "something you click" not "a rectangle with some 3d effect you can click on".
You can replace the ListBox's control template to get something like a list box with rounded corners or custom scroll bars.
A DataTemplate (ItemTemplate is a property of type DataTemplate) on the other hand let's you control how the data rows displayed inside list boxes (and other similar controls), data templates are used to specify things like "Show last name, than a comma and the first name - and the last name should be bold and the first name should be green if it starts with an A".
And just for completeness there is also an ItemsPanelTemplate class that is used to change the internal layout of a list box - Charles Petzold's WPF book has an example of using it to make a normal list box display it's items in a circle.
An ItemTemplate describes how to render the data item in a listbox (for example, you might have your listbox bound to a List - the ItemTemplate will allow you to specify how to render a Foo). An ItemTemplate is a DataTemplate.
A ControlTemplate describes how the ListBox itself should be rendered

Resources