12-24-2012 07:45 AM
How do I do that? Currently it's resized automatically to fit max tick label.
Solved! Go to Solution.
12-26-2012 12:43 PM
Hi EugeneM,
Can you post a picture of what you're seeing, and what you'd like instead? I'm not sure that I understand.
Thanks!
Alexandra
12-27-2012 01:44 AM
I need to fix width of selected area. Currently it depends on max length of numbers on the axis, e.g. if max value will be 1000.00 instead of 30.00 then axis will become wider...
12-28-2012 09:03 AM - edited 12-28-2012 09:04 AM
Hi EugeneM,
According to this help page about the minimum width property, the graph will always expand to fit the largest value on the axis.
Regards,
Alexandra
12-31-2012 06:14 AM
it seems to me that this reference is for WF graphs, not WPF, so it's not relevant
01-02-2013 11:14 AM
Hi EugeneM,
Whoops! The WPF also does not have an explicit property to set the width of the axis. You can change the visibility of the labels, and their orientation, which may help you with your space concerns.
What exactly are you trying to accomplish?
Regards,
Alexandra
01-02-2013 01:35 PM
As Alex+ra mentioned, you can customize the LabelVisibility
or LabelOrientation
properties on the MajorDivisions
of the vertical axis to change how the default labels are displayed. You can also customize the LabelPresenter
, using a fixed-width format or using a custom formatter that provides fixed-width labels:
<ni:AxisDouble Range="0,1000">
<ni:AxisDouble.MajorDivisions>
<ni:RangeLabeledDivisions LabelOrientation="Perpendicular" />
</ni:AxisDouble.MajorDivisions>
</ni:AxisDouble>
<ni:AxisDouble Range="0,1000">
<ni:AxisDouble.MajorDivisions>
<ni:RangeLabeledDivisions LabelPresenter="G1" />
</ni:AxisDouble.MajorDivisions>
</ni:AxisDouble>
<ni:AxisDouble Range="0,1000">
<ni:AxisDouble.MajorDivisions>
<ni:RangeLabeledDivisions>
<ni:RangeLabeledDivisions.LabelPresenter>
<ni:TemplateValuePresenter>
<ni:TemplateValuePresenter.Template>
<DataTemplate>
<Viewbox MaxWidth="16" StretchDirection="DownOnly">
<TextBlock Text="{Binding}" />
</Viewbox>
</DataTemplate>
</ni:TemplateValuePresenter.Template>
</ni:TemplateValuePresenter>
</ni:RangeLabeledDivisions.LabelPresenter>
</ni:RangeLabeledDivisions>
</ni:AxisDouble.MajorDivisions>
</ni:AxisDouble>
01-02-2013 01:58 PM
Hi, Paul!
This is much better. Now the only question is how do I combine this with ValueFormatter override? LabelPresenter doesn't allow to have both GeneralValueFormatter and TemplateValuePresenter...
<ni:RangeLabeledDivisions.LabelPresenter>
<!--ni:GeneralValueFormatter Format="0.00" /-->
<ni:TemplateValuePresenter>
<ni:TemplateValuePresenter.Template>
<DataTemplate>
<Viewbox Width="41" Stretch="None" HorizontalAlignment="Right" Margin="0,0,5,0">
<TextBlock Text="{Binding}" />
</Viewbox>
</DataTemplate>
</ni:TemplateValuePresenter.Template>
</ni:TemplateValuePresenter>
</ni:RangeLabeledDivisions.LabelPresenter>
01-02-2013 03:26 PM
I just used TemplateValuePresenter
as an easy XAML-only example. When you define your own value formatter, you can return whatever UI element you want to display. For example, if you were deriving from GeneralValueFormatter
, you could use code like below to wrap its visual in a Viewbox
:
protected override UIElement VisualizeCore<TData>( TData value, ValuePresenterArgs args, UIElement existingVisual ) {
var viewbox =
existingVisual as Viewbox
?? new Viewbox { MaxWidth = 16, StretchDirection = StretchDirection.DownOnly };
viewbox.Child = base.VisualizeCore<TData>( value, args, viewbox.Child );
return viewbox;
}
From your XAML snippet though, it looks like you just want to specify a .NET "0.00"
format. In that case, you can use the StringFormat
property provided by Binding
:
<TextBlock Text="{Binding StringFormat=0.00}" />