Hi,
I have a user control which includes XamDataChart with horizontal and vertical XamZoomBars.
This user control is appearing in 2 tabViews with different dataValues. When I change the zoom setting in tabItem1, it is also reflected in TabItem2 and vice versa.
I need to changes zoom settings individually. How can I achieve this behavior? Any thoughts?
This is the code snippet for adding XamZoombars.
<ig:XamZoombar x:Name="XamZoombarVertical" Orientation="Vertical" Margin="5,0,0,5" Grid.Column="1" Grid.RowSpan="2" Grid.Row="0"Range="{Binding ElementName=ChartMemoryData, Path=VerticalZoombar.Range, Mode=TwoWay}"/>
<ig:XamZoombar x:Name="XamZoombar" Margin="0,2,0,5" Grid.Row="3" ZoomChanged="XamZoombar_OnZoomChanged" Range="{Binding ElementName=ChartMemoryData, Path=HorizontalZoombar.Range, Mode=TwoWay}"/>
Hello Preeti,
Thank you for contacting Infragistics Developer Support!
I would recommend that you use the XamDataCharts built in zoombars instead of creating ones outside the chart:www.infragistics.com/.../datachart-chart-navigation
Hello Micheal,
Thanks for the response.
Even after using the built-in Zoombars for the data charts, I am getting the same behavior.
-Preeti
Thank you, Michael,
The Link (https://www.codeproject.com/Articles/460989/WPF-TabControl-Turning-Off-Tab-Virtualization) inside the given link in your answer helps me to achieve the desired behavior.
Thanks for the help.
-Preeti Gaur
Thank you for the update and code. I have done some looking into this matter. First thing I noticed is that you are setting the SyncChannel to a predetermined string which will put all your charts in the user control on the same channel. You will want to either not set that or set them to different. Nice is that you are using the TabControl which has a behavior that it re-used view instances when changing tabs. So this is most like the root cause of your charts zooming in sync, please see the following stackoverflow article:
stackoverflow.com/.../why-do-tab-controls-reuse-view-instances-when-changing-tab
Hello,
I am still not able to upload the project. I will copy the code for your reference.
Project Name : TestProjectZoomBarInTabViews
MainWindow.xaml
<Window x:Class="TestProjectZoomBarInTabViews.MainWindow" xmlns="">schemas.microsoft.com/.../presentation" xmlns:x="">schemas.microsoft.com/.../xaml" xmlns:d="">schemas.microsoft.com/.../2008" xmlns:mc="">schemas.openxmlformats.org/.../2006" xmlns:local="clr-namespace:TestProjectZoomBarInTabViews" mc:Ignorable="d" Title="MainWindow" Height="350" Width="525"> <Window.DataContext> <local:MainWindowViewModel/> </Window.DataContext> <Grid> <DockPanel> <TabControl ItemsSource = "{Binding Path=ViewModels}" SelectedIndex ="0"> <TabControl.ItemTemplate> <!-- this is the header template--> <DataTemplate> <WrapPanel Orientation="Horizontal" > <TextBlock Text="{Binding Name}"/> </WrapPanel> </DataTemplate> </TabControl.ItemTemplate> <TabControl.ContentTemplate> <!-- this is the body of the TabItem template--> <DataTemplate> <local:UserControlView/> </DataTemplate> </TabControl.ContentTemplate> </TabControl> </DockPanel> </Grid></Window>
MainWindowViewModel.cs
using System.Collections.ObjectModel;
namespace TestProjectZoomBarInTabViews{ public class MainWindowViewModel { private Collection <ViewModel> m_ViewModels = new Collection <ViewModel> ();
public Collection <ViewModel> ViewModels => m_ViewModels;
public MainWindowViewModel () { var viewModel1 = new ViewModel ("Name1"); m_ViewModels.Add(viewModel1); var viewModel2 = new ViewModel("Name2"); m_ViewModels.Add(viewModel2); } }
public class ViewModel { public ViewModel(string name) { this.Name = name; }
public string Name { get;set; } }}
UserControlView.xaml
<UserControl x:Class="TestProjectZoomBarInTabViews.UserControlView" xmlns="">schemas.microsoft.com/.../presentation" xmlns:x="">schemas.microsoft.com/.../xaml" xmlns:mc="">schemas.openxmlformats.org/.../2006" xmlns:d="">schemas.microsoft.com/.../2008" xmlns:local="clr-namespace:TestProjectZoomBarInTabViews" mc:Ignorable="d" xmlns:ig="">schemas.infragistics.com/xaml" d:DesignHeight="300" d:DesignWidth="300"> <Grid> <ig:XamDataChart x:Name="ChartMemoryData" Grid.Row="0" Grid.Column="0" MinHeight="200" VerticalZoombarVisibility="Visible" IsVerticalZoomEnabled="True"> <ig:SyncManager.SyncSettings> <ig:SyncSettings SyncChannel="syncGroup1" SynchronizeHorizontally="True" SynchronizeVertically="True" /> </ig:SyncManager.SyncSettings> <ig:XamDataChart.Axes> <ig:CategoryXAxis Name="XAxisData1" MinorStrokeThickness="0" MajorStrokeThickness="0" MajorStrokeDashArray="1" MajorStroke="#CCCCCC" Label="Time"> <ig:CategoryXAxis.LabelSettings> <ig:AxisLabelSettings Visibility="Visible" /> </ig:CategoryXAxis.LabelSettings> </ig:CategoryXAxis> <ig:NumericYAxis Name="YAxisLoad" MaximumValue="50" MinimumValue="0" Title="Load" Label="{}{:F1}"> <ig:NumericYAxis.LabelSettings> <ig:AxisLabelSettings Location="OutsideLeft" Margin="2,0,0,0" FontFamily="Segoe UI" FontWeight="SemiBold" FontSize="11" Foreground="#4CA5FF" Visibility="Visible"/> </ig:NumericYAxis.LabelSettings> <ig:NumericYAxis.TitleSettings> <ig:TitleSettings FontFamily="Segoe UI" FontWeight="SemiBold" FontSize="11" Margin="5,0,5,0" Angle="-90"/> </ig:NumericYAxis.TitleSettings> </ig:NumericYAxis> </ig:XamDataChart.Axes> <ig:XamDataChart.Series> <ig:LineSeries Brush="#4DAF4A" XAxis="{Binding ElementName=XAxisData1}" YAxis="{Binding ElementName=YAxisLoad}"> </ig:LineSeries> </ig:XamDataChart.Series> </ig:XamDataChart> </Grid></UserControl>
References:
InfragisticsWPF4.Controls.Charts.XamDataChart.v19.1
InfragisticsWPF4.v19.1
UserControlView.xaml.cs and MainWindoe.xaml.cs contains only InitializeComponent ()in constructor.
Sorry for the formatting and I hope you will be able to create the project with the provided information.
Let me know if you face any difficulties.
Thanks,
Preeti Gaur
Hello Michael,
I am trying to attach the project but getting the error message that says "An error occurred. Please try again or contact admin". I will keep trying to attach sample project. Below is the reference for the sample once I will be able to attach the sample.
I am using Infragistics v19, you can check that in the references of the attached sample project.
I have created and attached a sample project that will describe the issue.
After you will compile and run the attached sample project, select any tab and change the zoom setting manually.
Move to another tab and you will notice that it is also zoomed. The requirement is that zoom settings should be specific to the individual tab.
Let me know if you face any issues in compiling or running the project.
Preeti
Thank you for the update.
The best way for us to assist you is if you provide a small isolated sample that we can run and use for debugging locally. If you are unable able to provide an isolated sample I may be able to give suggestions if you provide the code for your page.
Also what version of the controls are you using?