Hello,
I would like to use a custom tooltip for the stackedcolumnseries, but it seems not to work, although I tried it as suggested in other posts.
The item object is not haveing the right object information. It doesn't represent the item of the ItemsDataSource.
This is the error I get:
System.Windows.Data Error: 40 : BindingExpression path error: 'GroupId' property not found on 'object' ''5b61ea55-ba58-4112-a5dd-99d6c7f7c7ef__proxy' (HashCode=56811240)'. BindingExpression:Path=Item.GroupId; DataItem='DataContext' (HashCode=15915816); target element is 'Run' (HashCode=45754591); target property is 'Text' (type 'String')System.Windows.Data Error: 40 : BindingExpression path error: 'Value' property not found on 'object' ''5b61ea55-ba58-4112-a5dd-99d6c7f7c7ef__proxy' (HashCode=56811240)'. BindingExpression:Path=Item.Value; DataItem='DataContext' (HashCode=15915816); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
<UserControl.Resources> <DataTemplate x:Key="tooltipTemplate"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <TextBlock Grid.Row="0" Grid.Column="0" Margin="0,0,5,0"> <Run Text="Valve Nr"/><Run Text=":"/> </TextBlock> <TextBlock Grid.Row="0" Grid.Column="1"> <Run Text="{Binding Path=Item.GroupId}"/> </TextBlock> <TextBlock Grid.Row="1" Grid.Column="0" Margin="0,0,5,0"> <Run Text="{Binding Path=Series.Title}"/><Run Text=":"/> </TextBlock> <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Path=Item.Value}" /> </Grid> </DataTemplate> </UserControl.Resources>
<ig:XamDataChart.Series> <ig:StackedColumnSeries ItemsSource="{Binding ChartItemsGroup}" XAxis="{Binding ElementName=xAxis}" YAxis="{Binding ElementName=yAxis}" AutoGenerateSeries="True" Legend="{Binding ElementName=Legend}" SeriesCreated="StackedColumnSeries_SeriesCreated"> <ig:StackedColumnSeries.ToolTip> <Grid> <ContentPresenter Content="{Binding}" ContentTemplate="{StaticResource tooltipTemplate}"/> </Grid> </ig:StackedColumnSeries.ToolTip> </ig:StackedColumnSeries> </ig:XamDataChart.Series>
Where .Value and .GroupId are the properties of my object.
www.infragistics.com/.../custom-series-with-data-point-tracker
Hello Markus,
I attached a sample that I believe meets your requirements. Please review it and let me know if you have any questions.
WpfAppStackedColumnSerie.zip
Thanks for the sample. In my case the "ValueMemberPath" doesn't return the value, instead it returns the "KeyMemberPath".
Here is my mapping:
ChartItemsGroup = new GroupBy(); ChartItemsGroup.GroupMemberPath = nameof(CategoryValueGroupItem<Guid>.GroupId); ChartItemsGroup.KeyMemberPath = nameof(CategoryValueGroupItem<Guid>.Category); //GUID value ChartItemsGroup.ValueMemberPath = nameof(CategoryValueGroupItem<Guid>.Value); //double value
As you can see in the screenshot, the tooltip contains the GUID, which is mapped to the KeyMemberPath. Do you have an idea why that can be?
Forthermore, I also want to show the "GroupMember" Value. How can I do this?
<conv:KeyConverter x:Key="keyConverter"/> <DataTemplate x:Key="tooltipTemplate"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <TextBlock Grid.Row="0" Grid.Column="0" Margin="0,0,5,0"> <Run Text="Valve Nr"/><Run Text=":"/> </TextBlock> <TextBlock Grid.Row="0" Grid.Column="1"> <!--<Run Text="{Binding Path=Item.GroupId}"/>--> <Run Text="{Binding Series.ValueMemberPath, Converter={StaticResource keyConverter}, ConverterParameter='_Value'}"/> </TextBlock> <TextBlock Grid.Row="1" Grid.Column="0" Margin="0,0,5,0"> <Run Text="{Binding Path=Series.Title}"/><Run Text=":"/> </TextBlock> <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Path=DataItem.Value}" /> </Grid> </DataTemplate>
What you are seeing is to be expected. My sample included an additional textblock with another converter that shows the actual value using reflection. eg.<TextBlock Text="{Binding Series.ValueMemberPath, Converter={StaticResource keyConverter}, ConverterParameter='_Emission'}"/> <TextBlock Text=":"/> <TextBlock> <TextBlock.Text> <MultiBinding Converter="{StaticResource ValueFromMemberPath}"> <Binding Path="Series.ValueMemberPath"/> <Binding Path="Item"/> </MultiBinding> </TextBlock.Text> </TextBlock>
The first textblock shows the KeyMemberPath for the underlying data item followed by the property name of the ValueMemberPath of the groupby object. In the KeyConverter converter the valuememberpath of the groupby object is passed to the converter parameter and is replaced with string.empty, leaving only the value of the key for the object.*Note, binding DataItem.Value needs to be replaced with what I have in bold above.