I am building a series of SfLinearGauge controls in code. However, I am somewhat new to C# and newer to WPF, and don't understand yet how I can set the linearPointer.Value parameter after the control has been created. The examples on binding mainly refer to XAML and/or controls such as charts, and I have not been able to work out how to apply this understanding to simpler controls.
Is there an example/FAQ/tutorial on how to drive this parameter?
Many thanks.
|
<gauge:LinearScale.Pointers>
<gauge:LinearPointer PointerType="SymbolPointer"
Value="{Binding SymbolPointer}"
SymbolPointerHeight="10"
SymbolPointerWidth="10"
SymbolPointerPosition="Below"
SymbolPointerStroke="red" />
<gauge:LinearPointer PointerType="BarPointer"
Value="{Binding BarPointer}"
BarPointerStroke="red"
BarPointerStrokeThickness="10" />
</gauge:LinearScale.Pointers> |
|
private void Button_Click(object sender, RoutedEventArgs e)
{
var vm = this.DataContext as ViewModel;
vm.BarPointer = 80;
vm.SymbolPointer = 50;
} |
|
<gauge:LinearScale.Pointers>
<gauge:LinearPointer PointerType="SymbolPointer" x:Name="symbolPointer"
SymbolPointerHeight="10"
SymbolPointerWidth="10"
SymbolPointerPosition="Below"
SymbolPointerStroke="red" />
<gauge:LinearPointer PointerType="BarPointer" x:Name="barPointer"
BarPointerStroke="red"
BarPointerStrokeThickness="10" />
</gauge:LinearScale.Pointers> |
|
private void Button_Click(object sender, RoutedEventArgs e)
{
symbolPointer.Value = 80;
barPointer.Value = 50;
} |
|
private void Button2_Click(object sender, RoutedEventArgs e)
{
LinearPointer linearPointer = new LinearPointer();
linearPointer.PointerType = LinearPointerType.SymbolPointer;
linearPointer.Value = 60;
linearPointer.SymbolPointerHeight = 15;
linearPointer.SymbolPointerWidth = 15;
linearPointer.SymbolPointerPosition = LinearSymbolPointersPosition.Above;
linearPointer.SymbolPointerStroke = new SolidColorBrush(Color.FromRgb(91, 134, 229));
linearScale.Pointers.Add(linearPointer);
} |
Hi,
is there a way how to implement the same using MVVM pattern?
My problem is that if I have bound Pointers collection I can't add new pointers e.g. on button click. It works only in constructor.
Hi Ondrej,
We have found and fixed the reported scenario “cannot added new pointers dynamically to the bounded Pointers collection” in the WPF SfLinearGauge control from our end. Currently, the issue fix is in the testing phase. Once the automation is ensured, we will include this issue fix in our upcoming weekly NuGet release update, which is expected to roll out on July 16, 2024. We will update you once the release has been rolled out. We appreciate your patience until then.
Regards,
Vishal O.
Hi Ondrej,
We have fixed the reported scenario “cannot added new pointers dynamically to the bounded Pointers collection” in the WPF SfLinearGauge control and included the fix in our latest weekly NuGet release update version 26.1.42 which is available for download in nuget.org.
Root-cause: Property changed support for Pointers property is not provided.
We thank you for your support and appreciate your patience in waiting for this update. Please feel free to reach out to us if you would require any further assistance.
Regards,
Vishal O.