I'm trying to set up a SciChart VerticalLineAnnotation similar to the Drag Horizontal Threshold example in the SciChart example suite. I have the annotation bound to a property in my view model, but when dragging the annotation it continually sets the property to a value of 0.
I've tried setting the property value in code and it does move the line as you would expect indicating the binding is fine. I set a breakpoint on the property and confirmed the 0 value is coming from the control, not my code.
<sc:SciChartSurface x:Name="OverviewSurface"
Margin="5,2,5,2"
Background="White"
Grid.Row="2"
Grid.ColumnSpan="4"
Loaded="OnOverviewSurfaceLoaded"
RenderableSeries="{Binding ElementName=ChartSurface, Path=RenderableSeries}"
YAxes="{sc:AxesBinding YAxes}">
<sc:SciChartSurface.XAxis>
<sc:NumericAxis VisibleRange="{Binding VisibleRange}" DrawMajorGridLines="False" DrawMinorGridLines="False" DrawMajorBands="False" Visibility="Collapsed"/>
</sc:SciChartSurface.XAxis>
<sc:SciChartSurface.Annotations>
<sc:VerticalLineAnnotation VerticalAlignment="Stretch"
IsEditable="True"
ShowLabel="False"
Stroke="#FF42b649"
StrokeThickness="4"
YAxisId="ChannelA"
X1="{Binding SelectedIndex, Mode=TwoWay}" />
</sc:SciChartSurface.Annotations>
</sc:SciChartSurface>
I expect that when I drag the Annotation along the horizontal length of the chart that I will get a value corresponding with the X position placed in SelectedIndex, but all I ever get is zero.
The cause of this issue turned out to be the data type of SelectedIndex, which was an unsigned integer. Despite the fact that VerticalLineAnnotation's X/Y value type is IComparable, if you are using the IsEditable="True" function, the drag step size is fractional and if bound to an integer type, it will continually round to 0 making it incapable of movement.
If there is a way to change the step size of the drag in SciChart, I was unable to locate it. Instead I changed SelectedIndex to a double and rounded it to my desired unsigned integer in the setter, which solved my problem.
Related
I have a simple dialog with a SpinEdit control thot is supposed to work with integers and float values. It works correctly with integers, however it doesn't load float values. THe float value is loaded correctly to my Property but once the dialog opens it shows '0,00' instead of, say, '44,44'. If my float value has no decimal numbers it is also loaded correctly, so I can see values like '44,00'.
I tried casting to Decimal but to no avail. The only difference is that the value in my property has a dot '.' as a decimal placeholder while the SpinEdit shows a comma. From what I've read that shouldn't be a problem.
Here's my SpinEdit:
XAML:
<DataTemplate DataType="{x:Type local:TInputNumericVM}">
<dxe:SpinEdit x:Name="dxSpinEdit"
Text="{Binding Value, Mode=TwoWay}"
MaskType="Numeric"
IsFloatValue="{Binding FloatValue}"
MinValue="{Binding MinValue}"
MaxValue="{Binding MaxValue}"
Mask="{Binding Mask, Mode=TwoWay}"
MaxLength="{Binding Path=InputLength}"
MaskShowPlaceHolders="{Binding ShowPlaceHolder}"
InvalidValueBehavior="WaitForValidValue"
MaskUseAsDisplayFormat="True"
AllowRoundOutOfRangeValue="True"
Increment="{Binding IncrementStep}"
/>
</DataTemplate>
With 'IsFloatVakue = true', 'Mask = f', 'MaskShowPlaceholders = True'
EDIT:
I have managed to display the float value with a temporary workaround. I threw away the MaskUseAsDisplayFormat="True" property and used FormatDisplayString property where I set the value to "###.##". I'm not satisfied with this solution, but it works for now, the question is still opened and I'd appreciate further suggestions.
EDIT2:
I'm working on devexpress ver 16.1.6 and after consultations with my colleague he suggests that the MaskUseAsDisplayFormat property may work properly on a newr version but I can't use the newer version so I won't be checking it.
I am using the SpinEdit as well to display float/double values. Here is the code, which works for me:
<dxe:SpinEdit MinValue="1" Increment="0.5"
Mask="f1" MaskUseAsDisplayFormat="True" IsTextEditable="True"
EditValueType="{x:Type system:Double}"
EditValue="{Binding Path=XYZ, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
Guess the important properties to set are "Mask" and "EditValueType".
Using DevExpress 17.2.4.
I do not manage to properly set the width of my XAML ToggleSwitch.
My code is as follows:
<Controls:ToggleSwitch OnLabel="True"
OffLabel="False"
IsEnabled="{Binding CheckValueEnable}"
IsChecked="{Binding CheckValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="250" >
</Controls:ToggleSwitch>
Whatever Width value I set, there is a too big spacing between the text (true / false) and the visual toggle button.
How can I decrease this spacing?
I would guess your issue (over exaggerated a little) is something like this:
{O }___________True
What you want is:
{O }__True
Without knowing the control it is a bit difficult but i would guess you only option is to modify the ToggleSwitch's ControlTemplate to define the content presenter position
EDIT:
Further to that, you might find the following article useful as it describes the process of editing controls in XAML
http://docs.telerik.com/devtools/wpf/styling-and-appearance/styling-apperance-editing-control-templates
I want to set size of change after use one from two buttons connected with NumericUpDown control.
I have something like this:
<toolkit:NumericUpDown Grid.Column="1" Minimum="2" ValueFormat="F0" Value="4" LargeChange="1" Maximum="10"/>
In WPF's NumericUpDown is property "increment", but I this I can't find. I think that it can be LargeChange, but it not working for me. I want to set increment = 1.
In example increment is 0,1
Thanks
Set the SmallChange to 1. This will result in the change of 1 every time you increment the value.
<toolkit:NumericUpDown ValueFormat="F0" Value="4" SmallChange="1" Maximum="10" />
I'm using ICSharpCode's AvalonEdit text editor, and I display different TextEditor controls in a TabControl after a Document list.
The WPF code of the TabControl :
<TabControl
Grid.Row="0"
ItemsSource="{Binding OpennedFiles, UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="Data.Name"
SelectedItem="{Binding SelectedFile, UpdateSourceTrigger=PropertyChanged}">
<TabControl.ContentTemplate>
<DataTemplate>
<AE:TextEditor ShowLineNumbers="True" FontFamily="Consolas" Unloaded="TextEditor_Unloaded" FontSize="16" Loaded="TextEditor_Loaded" Document="{Binding Document}" SyntaxHighlighting="Python" />
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
My problem is that when you change the selectionned tab, the caret offset of the previously selected document is reset to 0, which is really annoying.
I've tried to bind the caret offset property of the text editor, but it's not a dependency property, and since I'm not really sure it would work, I did not have the courage to create an attached dependency property.
I suspect that it comes from the fact that the Document is reloaded in the text editor at the tab selection, and since the caret offseet seems to depend from the TextArea, it returns to its default value, but I still don't have any idea on how to avoid this.
Any hints ?
try saving the caret offset to a database and then set the values back during loading of the texteditor
this.ScrollToVerticalOffset(value1); //top offset of the editor (example line 120)
this.TextArea.Caret.Line = value2; //value of the cursor line
I am trying to use the ProgressBar as a representation of a percent value (I have not found an alternative control that looks right).
I am trying to set the value. It is my understanding that just setting the Value property should work, and update the control when my current event handler ends and control passes back to the UI.But no matter what I set the value to, the bar stays empty.
Here is my XAML:
<ProgressBar Name="LevelProgress" Maximum="100" Minimum="0" />
and my C#:
LevelProgress.Value = 43.0;
I have also tried:
LevelProgress.SetValue(ProgressBar.ValueProperty,43.0);
Even setting the Value property in the XAML definition does not work.
I really don't want to have to setup some big background thread thing just to set this value. Can anyone recommend a solution, or an alternative control?
Works for me
Do you
InitializeComponent();
Before?
LevelProgress.Value = 43.0;
I put it in the Loaded event and it worked there.
And I tried
<ProgressBar Name="LevelProgress" Maximum="100" Minimum="0" Value="43" />
And it works there. Something is wrong with the progress bar.