Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
125
xamChart Datapoint's value Binding Issue
posted

H! there

I am facing binding problem with Xamchart for quiet sometime.

i explain you the scenario and problem as well

I am trying to bind xmachart with a List collection.

Xamchart is inside the grid layout control. i have set datacontext of my grid to selecteditemlist.

Functionality-

here what i am doing is . on basis of selection of an item from XamDatagrid the selected items id i get the a list of values from database and bind it to xamchart and two listbox control which are there inside the Grid.

On selection change the value for listboxitems changes but value of Xamchart's datapoint doesnt change. the same item value is binded to listbox item it works fine for it but the same fields vlaue is not reflected in Datapoint's value property. It doesnt update the value of Datapoint based on the selection of row from xamdatagrid.

It does the binding for the first time means when i run the application and i select a row from xamdatagrid it binds the respective value for the first time. But when i try to select another row or item from xamdatagrid the value doenst change or update. For the first time selection it sets datapoint Values but on next or second selection it doesnt update the Datapoint value with the respective values and same works for the listbox which also binded with the same field.

I hope i explaind my problem also i past the XAMl code plz go through it and let me know whats the problem is it from my side or there is some other way of binding the Xamdatapoints.

 

<Grid DataContext="{Binding SelectedItemList}">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <ListBox Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Margin="0,0,8,0"   IsEnabled="False"
                                      ItemsSource="{Binding}"
                                      ItemTemplate="{StaticResource ListBoxTemplate}" AlternationCount="2">
                                    </ListBox>

                                    <ListBox Grid.Row="0"  Grid.Column="1" VerticalAlignment="Center"  IsEnabled="False"
                                      ItemsSource="{Binding}"
                                      ItemTemplate="{StaticResource ListBoxTemplate2}" AlternationCount="2">
                                    </ListBox>
                                    <Grid Grid.Row="0" Grid.Column="2">                                       

                                        <igCA:XamChart   VerticalAlignment="Top"  MaxWidth="450">
                                           
                                                <igCA:XamChart.Legend>
                                                <igCA:Legend MarginType="Percent" Foreground="#FFE6E6E6" Margin="70,10,10,55" />

                                        </igCA:XamChart.Legend>
                                        <igCA:XamChart.Axes>
                                            <igCA:Axis AxisType="PrimaryX" >
                                                <igCA:Axis.Label>
                                                    <igCA:Label FontSize="12" AutoResize="False"  Angle="0" Foreground="#FFE6E6E6"/>
                                                </igCA:Axis.Label>
                                            </igCA:Axis>
                                            <igCA:Axis AxisType="PrimaryY" Stroke="Transparent" >
                                                    <igCA:Axis.MajorGridline >
                                                        <igCA:Mark StrokeThickness="0" Visible="False" />
                                                    </igCA:Axis.MajorGridline>

                                                    <igCA:Axis.MinorGridline>
                                                        <igCA:Mark  Visible="False" Unit="50"  />
                                                    </igCA:Axis.MinorGridline >

                                                    <igCA:Axis.Label>
                                                        <igCA:Label FontSize="10.5"  Angle="0" Foreground="#FFE6E6E6"/>
                                                   
                                                </igCA:Axis.Label>
                                            </igCA:Axis>
                                        </igCA:XamChart.Axes>

                                        <igCA:XamChart.Series  >
                                                <igCA:Series Label="Delayed"  >
                                                    <igCA:Series.Fill>
                                                        <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                                                            <GradientStop Color="#FF96000E" Offset="0"/>
                                                            <GradientStop Color="sc#1, 0.5881772, 0, 0.002195721" Offset="0.27256536483764648"/>
                                                            <GradientStop Color="#FFF00000" Offset="1"/>
                                                        </LinearGradientBrush>
                                                    </igCA:Series.Fill>
                                                        <igCA:Series.DataPoints>
                                                        <igCA:DataPoint  Label="By Phone" Value="{Binding Path=Delayed}" >
                                                            <igCA:DataPoint.Fill>
                                                                <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                                                                    <GradientStop Color="#FF96000E" Offset="0"/>
                                                                    <GradientStop Color="sc#1, 0.5881772, 0, 0.002195721" Offset="0.27256536483764648"/>
                                                                    <GradientStop Color="#FFF00000" Offset="1"/>
                                                                </LinearGradientBrush>
                                                            </igCA:DataPoint.Fill>
                                                           
                                                        </igCA:DataPoint>
                                                        <igCA:DataPoint Label="By Email" Value="{Binding Path=Delayed}" >
                                                            <igCA:DataPoint.Fill>
                                                                <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                                                                    <GradientStop Color="#FF96000E" Offset="0"/>
                                                                    <GradientStop Color="sc#1, 0.5881772, 0, 0.002195721" Offset="0.27256536483764648"/>
                                                                    <GradientStop Color="#FFF00000" Offset="1"/>
                                                                </LinearGradientBrush>


                                                            </igCA:DataPoint.Fill>
                                                        </igCA:DataPoint>
                                                        <igCA:DataPoint Label="By Meeting" Value="{Binding Path=Delayed}" >
                                                            <igCA:DataPoint.Fill>
                                                                <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                                                                    <GradientStop Color="#FF96000E" Offset="0"/>
                                                                    <GradientStop Color="sc#1, 0.5881772, 0, 0.002195721" Offset="0.27256536483764648"/>
                                                                    <GradientStop Color="#FFF00000" Offset="1"/>
                                                                </LinearGradientBrush>


                                                            </igCA:DataPoint.Fill>
                                                        </igCA:DataPoint>

                                                    </igCA:Series.DataPoints>
                                            </igCA:Series>
                                                <igCA:Series Label="OnTarget" >
                                                    <igCA:Series.Fill>
                                                        <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                                                            <GradientStop Color="#FF47822F" Offset="0"/>
                                                            <GradientStop Color="sc#1, 0.106484905, 0.348379731, 0.0431157351" Offset="0.38600993156433105"/>
                                                            <GradientStop Color="#FF6CB744" Offset="1"/>
                                                        </LinearGradientBrush>
                                                    </igCA:Series.Fill>
                                                    <igCA:Series.DataPoints>
                                                        <igCA:DataPoint Label="By Phone" Value="{Binding Path=OnTarget}" >
                                                            <igCA:DataPoint.Fill>
                                                                <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                                                                    <GradientStop Color="#FF47822F" Offset="0"/>
                                                                    <GradientStop Color="sc#1, 0.106484905, 0.348379731, 0.0431157351" Offset="0.38600993156433105"/>
                                                                    <GradientStop Color="#FF6CB744" Offset="1"/>
                                                                </LinearGradientBrush>

                                                            </igCA:DataPoint.Fill>
                                                        </igCA:DataPoint>
                                                        <igCA:DataPoint Label="By Email" Value="{Binding Path=OnTarget}">
                                                            <igCA:DataPoint.Fill>
                                                                <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                                                                    <GradientStop Color="#FF47822F" Offset="0"/>
                                                                    <GradientStop Color="sc#1, 0.106484905, 0.348379731, 0.0431157351" Offset="0.38600993156433105"/>
                                                                    <GradientStop Color="#FF6CB744" Offset="1"/>
                                                                </LinearGradientBrush>
                                                            </igCA:DataPoint.Fill>
                                                        </igCA:DataPoint>
                                                        <igCA:DataPoint Label="By Meeting" Value="{Binding Path=OnTarget}" >
                                                            <igCA:DataPoint.Fill>
                                                                <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                                                                    <GradientStop Color="#FF47822F" Offset="0"/>
                                                                    <GradientStop Color="sc#1, 0.106484905, 0.348379731, 0.0431157351" Offset="0.38600993156433105"/>
                                                                    <GradientStop Color="#FF6CB744" Offset="1"/>
                                                                </LinearGradientBrush>
                                                            </igCA:DataPoint.Fill>
                                                        </igCA:DataPoint>
                                                    </igCA:Series.DataPoints>
                                            </igCA:Series>
                                        </igCA:XamChart.Series>
                                    </igCA:XamChart>
                                    </Grid>
                                </Grid>

Parents
No Data
Reply
  • 30692
    Suggested Answer
    Offline posted

    I don't think the way you are going about the binding is valid.

    Do you have a fixed number of items in your list or something of this nature?

    When you are binding a list to the chart the easiest way of going about it is to use the

    DataSource and DataMapping properties.

    For example, in your case the items you want to fill the series are in {Binding}

    So if you set the properties on the series like this:

    DataSource="{Binding}" DataMapping="Label = Label; Value = Delayed"

    for example, then you would have better results. This would rely on come value in your data source holding the label for each data point.

    If that isnt possible, you may be able to pursue your current strategy if you used some indexers in the value bindings to select the correct item from the selecteditems list, e.g. Value={Binding [0].Delayed} or something of that nature.

    What does the data in the selecteditems list look like?

    Hope this helps!

    -Graham

Children
No Data