How can the width of a chart in wpf be adjusted? - wpf

I am using the chart control from the WPF Toolkit. My question is simple, when my chart is displayed, the column is expanded to the width of the screen.
Is there a way to specify a maximum width? Thanks in advance.

You can specify a width explicitly via the Width property, or allow an element to expand up to a certain size via the MaxWidth property. These properties are common to all UI elements, not just charts.
See the FrameworkElement documentation.

Related

autosize height of gridcontrol in list

I've got a winforms application, using devexpress library. In this application I have an overview form with a list of datagrids (gridview controls of devexpress). The number of rows is dynamic, so is the number of datagrids shown. The grids are programatically added to a panel on the form.
The width of the grids need to scale with the width of the form. I managed to do that by setting the property docking to "top". The height of the grids should scale based on the rows inside. But I can't make this happen.
How can I add a grid to the panel (or form) with width set to 100% and height based to content of the grid?
Refer this - Calculate the "perfect" size/height of a Grid
The height of the grid content can be calculated via the ViewInfo
object. Follow approach from the How to change the Grid's height
according to the total height of its rows example.

How to change WPF Ribbon Menu AuxiliaryPaneContent width

In WPF Ribbon menu, width of AuxiliaryPaneContent (in RibbonApplicationMenu) is not available. How to change its width based on the items present in it?
There is no direct property to set the Width or Height of AuxiliaryPaneContent. The solution given here may help: AuxilaryPane Size.

Silverlight - Setting width of inner control based on width of container control

I have a peculiar requirement related to setting width of controls in silverlight. Generally when UI renders in Silverlight, width of container control is calculated based on widths of child controls. I have a requirement where layout of the application can change drastically. One of the scenarios is that I have a Grid cotaining listboxes in each column. These column can have several user controls. Now I want to set width of user controls to expand as much as possible to stretch for width of listbox control. Is there some way to do this? If I set fixed width of user controls, it could leave some area blank on UI or horizontal scroll in listbox may appear. If I set "Auto" width of user control, there could be some unused space in UI. Is there any way to deal with this issue?
Set the HorizontalAlignment of your usercontrols to System.Windows.HorizontalAlignment.Stretch. Note that you should leave your Width unset if you do this, as it takes precedence over HorizontalAlignment.

How to resize multiple WPF controls when the text size changes?

What's the correct pattern to resize controls when a font size changes?
For example, I used the WPF designer to make a form, and placed UI elements from the toolbox. Late in the game I got the requirement that the font size of every UI element needs to be configurable, so now I'm thinking there has to be a better way to resize controls when the font size changes. Right now I'm doing alot of code behind calculations on Margin properties.
For such cases I usually place my control inside Grids and StackPanels, this way font size won't affect the layout, everything will be stretchable.
Never place controls on the Window using absolute coordinates.
Make sure your Height and Width on the controls are set to Auto.
When you use the designer/toolbox to add controls it usually provides a static height/width. If you type the tag in the XAML editor you get the control default which is usually Auto.
You'll notice the black diamond in the property window next to the attributes that are changed from their default value. You can right click and choose reset value to clear the attribute from your XAML and see what the default value is.

How to calculate a bounding box for an Expander?

I have an Expander control and i need to calculate its bounds without invisible elements and margins. It commonly can be done by VisualTreeHelper.GetDescendantsBounds. But it seems that the rect is calculated by VisualTreeHelper doesn't depend on the expander state. For example:
http://i.piccy.info/i5/58/39/273958/collapsed.jpg
(i can't post images. sorry)
The same result as for expanded state (light green rectangle on the image). Does anybody know how to solve this problem?
The Expander control will set its content's visibility to Collapsed, which means it won't be considered during layout and won't be included in GetDescendantBounds. However, the Expander can be forced to have a larger size by the layout engine, and the Expander's own size is included in GetDescendantBounds.
Try setting VerticalAlignment="Top" on the Expander. The default is Stretch, which will allow it to increase in size if the parent has more space available. Also make sure you aren't explicitly setting the Height property.
This is the sample application. The style is applied here to the TreeView control and its items. But the problem doesn't depend on the style.

Resources