Hello,
I can't handle mouse events on AxisLabelPanel (HorizontalAxisLabelPanel). By default panels transparent for such input events and I can't set background of HorizontalAxisLabelPanel. I tried Background property directly and style with TargetType="HorizontalAxisLabelPanel" but everything is vain.
Could you help?
Infragistics team, could you please tell me how can I set background of axis?
Even when I override axis template like this:
<ig:CategoryXAxis.Template> <ControlTemplate TargetType="ig:Axis"> <Canvas x:Name="RootCanvas" Background="White"/> </ControlTemplate> </ig:CategoryXAxis.Template>
it applies to series area (series area became white) not to axis. I can't understand why.
Hello Dmitry,
Thank you for your email. I have been looking into your question and the Background of the axes panels is null by default, as you mentioned, and this causes the mouse events to not fire. What I can suggest is using the Loaded event of the XamDataChart to get the panels and set the Background to Transparent (instead of null) and also handle the events of the panels there. I am attaching a sample application that shows how you can handle the MouseMove events of the x and y axis panels.
Please let me know if I can assist you with anything else.
Sincerely,
Krasimir, MCPD
Developer Support Supervisor - XAML
Infragistics
www.infragistics.com/support
Thank you for your post. I am very glad that you have managed to find a solution for your issue. Please let me know if you need any further assistance on the matter.
Found solution:
<ig:CategoryXAxis.LabelPanelStyle> <Style TargetType="ig:HorizontalAxisLabelPanel"> <Setter Property="Background" Value="Transparent"/> </Style></ig:CategoryXAxis.LabelPanelStyle>
I don't see where to attach files.Thank you for your reply.OK, it's acceptable but I can't use it because suggested solution is suitable only for simple situations. Perhaps I confused you with a simple example.Assume that we have more complex situation: more axes and series and EventToCommand (MVVM Light). What can I do in that case?The example at bottom of my post is essentially close to my real project except that I add axes and series dynamically there (http://es.infragistics.com/community/forums/t/93404.aspx). So another question: What to do in case when axes and series are added after XamDataChart has been loaded, after all "Loaded" event fires only once?Certainly I can look through visual tree and set background directly as you suggested. But maybe there is more elegant solution avoiding pollution of control's code and respecting MVVM?View:<UserControl x:Class="ChartControl.ChartControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:ig="http://schemas.infragistics.com/xaml" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras" xmlns:common="clr-namespace:ChartControl.Common" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300"> <Grid Background="Azure" DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=ViewModel}"> <ig:XamDataChart> <ig:XamDataChart.Resources> <common:PanArgsConverter x:Key="PanArgsConverter"/> </ig:XamDataChart.Resources> <ig:XamDataChart.Axes> <ig:NumericYAxis x:Name="YAxis1"/> <ig:CategoryXAxis x:Name="XAxis1" ItemsSource="{Binding Data1}" Label="{}{X}"> <ig:CategoryXAxis.LabelSettings> <ig:AxisLabelSettings Location="OutsideTop"/> </ig:CategoryXAxis.LabelSettings> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseMove"> <command:EventToCommand Command="{Binding CustomizablePanCommand}" EventArgsConverter="{StaticResource PanArgsConverter}" EventArgsConverterParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ig:CategoryXAxis}}" PassEventArgsToCommand="True"/> </i:EventTrigger> </i:Interaction.Triggers> </ig:CategoryXAxis> <ig:NumericYAxis x:Name="YAxis2"/> <ig:CategoryXAxis x:Name="XAxis2" ItemsSource="{Binding Data2}" Label="{}{X}"> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseMove"> <command:EventToCommand Command="{Binding CustomizablePanCommand}" EventArgsConverter="{StaticResource PanArgsConverter}" EventArgsConverterParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ig:CategoryXAxis}}" PassEventArgsToCommand="True"/> </i:EventTrigger> </i:Interaction.Triggers> </ig:CategoryXAxis> </ig:XamDataChart.Axes> <ig:XamDataChart.Series> <ig:LineSeries ItemsSource="{Binding Data1}" ValueMemberPath="Y" XAxis="{Binding ElementName=XAxis1}" YAxis="{Binding ElementName=YAxis1}"/> <ig:LineSeries ItemsSource="{Binding Data2}" ValueMemberPath="Y" XAxis="{Binding ElementName=XAxis2}" YAxis="{Binding ElementName=YAxis2}"/> </ig:XamDataChart.Series> </ig:XamDataChart> </Grid></UserControl>ViewModel:using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.Linq;using System.Text;using ChartControl.Common;namespace ChartControl{ public class ChartControlViewModel : NotifyPropertyChangedBase { public ChartControlViewModel() { var date = DateTime.Now; for (var i = 0; i < 10; i++) this._data1.Add(new DataItem { X = (date = date.AddMinutes(1)), Y = i }); for (var i = 10; i > 0; i--) this._data2.Add(new DataItem { X = (date = date.AddMinutes(1)), Y = i }); } private readonly ObservableCollection<DataItem> _data1 = new ObservableCollection<DataItem>(); public ObservableCollection<DataItem> Data1 { get { return this._data1; } } private readonly ObservableCollection<DataItem> _data2 = new ObservableCollection<DataItem>(); public ObservableCollection<DataItem> Data2 { get { return this._data2; } } private RelayCommand<object> _customizablePanCommand; public RelayCommand<object> CustomizablePanCommand { get { return this._customizablePanCommand ?? (this._customizablePanCommand = new RelayCommand<object>(obj => { // TODO })); } } }}