RadChart does not display/render when place in a ListBox or ItemsControl

7 posts, 0 answers
  1. Patrick Fletcher
    Patrick Fletcher avatar
    19 posts
    Member since:
    Jun 2009

    Posted 12 Aug 2009 Link to this post

    My RadChart does not display when place in a ItemsControl or a ListBox, when the RadChart is part of a DataTemplate that varies on DataType, no plots of my Datapoints are render.  Telerik, what's up with that, why can't RadChart render in a ItemsControl and/or ListBox?.
  2. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 13 Aug 2009 Link to this post

    Hello Patrick Fletcher,

    Unfortunately we are unable to reproduce the problematic behavior in our local tests. Please review the attached sample application that demonstrates our observations and let us know how we can observe the erroneous issue locally so we can investigate it further.


    Regards,
    Manuel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Patrick Fletcher
    Patrick Fletcher avatar
    19 posts
    Member since:
    Jun 2009

    Posted 13 Aug 2009 Link to this post

    I am sorry, but what you did is much simpler than what I am trying to do.  Firstly, I am styling my ListBox using a style template.  Secondly, I am binding to a four level nested ObservableCollection.  Thirdly, I am using a PanelBar as the Master, and a ItemsControl/ListBox as the Detail for showing RadChart plots of DataPoints but the points are not being render even though the ListBoxItem ContentPresenter infact receives those datapoints.  I used the tool 'Mole' to debug and it clearly shows that the ListBoxItem receives the datapoints.  Fourthly, I am using no code-behind in the '.xaml.cs' file, as it should not be necessary.  The only code-behind that is used in '.xaml.cs' is in the constructor where I set the DataContext to the collection. Note,  I am using a random generator in the Subcomponent class to generate datapoints for the chart. 

    When I click on a subcomponent under the gear or bearings category, I am expecting to see plots of datapoints appearing in radcharts in a ListBox.  For some reason(s), that is not happening.

    1.  Collection Architecture:
    ---------------------------------

     

    public class AirMechViewModel
    {

     

        private CategoryCollection subcomponentCategoryCollection;

     

     

     

     

     

        public AirMechViewModel()

         {

            subcomponentCategoryCollection =

    new CategoryCollection();

     

     

         }

     

        public Window1 View { get; set; }
     

     

     

        public ObservableCollection<Category> MechanicalDiagnosticCategories
        { 

     

            get { return subcomponentCategoryCollection; }

     

     

        }

    }

     

    public

     

    class CategoryCollection : ObservableCollection<Category>

     

     

    {

     

            public CategoryCollection()

     

     

            {

                    Populate();

            }

     

     

     

     

     

            protected virtual ObservableCollection<SubcomponentItem> GearSubcomponentTemplateTables() 

            {

     

                   ObservableCollection<SubcomponentItem> gearSubcomponentTemplateTables = new 
                                                                                        ObservableCollection<SubcomponentItem>();

     

     

                   gearSubcomponentTemplateTables.Add(

    new SubcomponentItem("Residual Kurtosis"));

     

     

                   gearSubcomponentTemplateTables.Add(

    new SubcomponentItem("Residual RMS"));

     

     

     

                   return gearSubcomponentTemplateTables;

     

     

             }
     

     

            protected virtual ObservableCollection<SubcomponentItem> BearingSubcomponentTemplateTables() 

            {

     

                    ObservableCollection<SubcomponentItem> bearingSubcomponentTemplateTables = new 
                                                                                         ObservableCollection<SubcomponentItem>();

     

     

                    bearingSubcomponentTemplateTables.Add(

    new SubcomponentItem("Envelope RMS"));

     

     

                    bearingSubcomponentTemplateTables.Add(

    new SubcomponentItem("Envelope Inner Race Energy"));

     

     

     

                   return bearingSubcomponentTemplateTables;

     

     

             }

     

     

          private void Populate()

     

          {

                    Add(

    new Category("GEAR"));
                    this[0].SubcomponentCollection.Add(new GearSubcomponent("Left Input Spiral Bevel Pinion 22T"
                                                                              GearSubcomponentTemplateTables(), subcomponentConstantsCollection));
                    this[0].SubcomponentCollection.Add(new GearSubcomponent("Left Input Spiral Bevel Gear 80T"
                                                                              GearSubcomponentTemplateTables(), subcomponentConstantsCollection));
                    Add(new Category("BEARINGS"));
                    this[1].SubcomponentCollection.Add(new BearingSubcomponent("Fan Bearing", BearingSubcomponentTemplateTables());

     

     

     

     

                    this[1].SubcomponentCollection.Add(new BearingSubcomponent("Hydraulic Pump 4 Preload"
                                                                              BearingSubcomponentTemplateTables());

     

     

     

     

         }
    }
     

     

     

    public

     

    class Category

     

     

     

     

    {

     

     

     

            private ObservableCollection<Subcomponent> subcomponentCollection;

     

     

     

            public Category(string categoryName)

     

     

            {

                    subcomponentCollection =

    new ObservableCollection<Subcomponent>();

     

     

     

                   this.categoryName = categoryName;

     

     

             }
     

     

            public ObservableCollection<Subcomponent> SubcomponentCollection 

            {

     

                    get { return subcomponentCollection; }

     

     

     

                    set {subcomponentCollection = value;}
            }
     

     

     

     

            public string CategoryName 

            {

     

                    get { return categoryName; }

     

     

     

                    set {categoryName = value;}

     

     

            

    }

     

     

     

     

    }

     

     

     

    public

     

    class Subcomponent

     

     

    {

     

            private ObservableCollection<SubcomponentItem> subcomponentItems;

     

     

     

            private String componentName;

     

     

     

            private String subcomponentName;

            public
    Subcomponent()

     

     

     

     

             {

                    subcomponentItems =

    new ObservableCollection<SubcomponentItem>();

     

     

                    subcomponentName =

    String.Empty;

     

     

                    componentName = 

    String.Empty;

     

     

     

            }

     

     

     

     

     

           public virtual ObservableCollection<SubcomponentItem> SubcomponentItems

     

     

     

            {

     

                    get { return subcomponentItems; }

     

     

     

                    set {subcomponentItems = value;}

     

     

             }

     

            public virtual String ComponentName 

            {

     

                    get { return componentName; }

     

     

     

                    set {componentName = value;}

     

     

            }

     


            public
     virtual String SubcomponentName

     

     

            {

     

                    get { return this.subcomponentName; }

     

     

     

                    set {this.subcomponentName = value;}

     

     

             }
     

     

     

            public

     

    virtual void GetGraphDataPoints(String subcomponentName, ObservableCollection<SubcomponentItem
            subcomponentItems
    )

     

     

            {

     

     

                   this.subcomponentItems = subcomponentItems; 

     

                   this.subcomponentName = subcomponentName;

     

     

     

     

     

     

                   for (int index = 0; index < subcomponentItems.Count; index++) 

                    {

     

                        subcomponentItems[index].InitiateDataPoints(current[subcomponentItems[index].ChartName.ToLower()]);

                    }

            }

     

     

     

    }

    public class SubcomponentItem

     

     

     

     

     

     

    {

     

     

     

            private ObservableCollection<DataPoint> conditionIndicatorDataPoints; // A list will also suffice

     

     

     

     

            private string chartName;

     

     

     

     

     

     

     

            public SubcomponentItem(string chartName) 

            {

     

                    this.chartName = chartName;

     

     

     

                   this.conditionIndicatorDataPoints = new ObservableCollection<DataPoint>();

     

     

             }

     

     

     

     

     

            public ObservableCollection<DataPoint> ConditionIndicatorDataPoints

             {

     

                    get { return conditionIndicatorDataPoints; }

     

     

     

                    set {conditionIndicatorDataPoints = value;}

     

     

             }
     

     

            public string ChartName 

            {

     

                    get { return chartName; }

     

     

     

                    set {chartName = value;}

     

     

             }

      

     

            public void InitiateDataPoints()

            {

     

                    Random rand = new Random(DateTime.Now.Millisecond);

     

     

     

                    for (int index = 0; index < 6; index++)

     

     

                     {

     

                           conditionIndicatorDataPoints.Add(new DataPoint(Math.Round(rand.NextDouble() * 10, 2)));

     

     

     

                   }
            }
    }
     

     

     

    public

     

    class DataPoint

     

     

     

     

    {

     

     

     

            private double yPlotPoint;

     

     

     

            public DataPoint()

     

     

            {

                    yPlotPoint = 0.0;

     

            }

     

     

     


            public
    DataPoint(double plotPoint)

     

     

     

            {

     

                    this.yPlotPoint = plotPoint;

     

     

     

            }

     

     

     


            public
    double YPlotPoint

             {

     

                    get { return yPlotPoint; }

     

     

            }

     

    }


    2.  Data Types for Collection:
    ------------------------------------

     

     

     

    public

     

    class GearSubcomponent: Subcomponent

     

     

     

     

     

    {

     

     

     

     

     

            public GearSubcomponent()

     

            {}

     

     

            public GearSubcomponent(string subcomponentName, ObservableCollection<SubcomponentItem> subcomponentItems)

     

            {

                    GetGraphDataPoints(subcomponentName, subcomponentItems);

            }

     

     

     

     

    }

     

     

    public class BearingSubcomponent: Subcomponent

     

     

     

     

     

    {

     

     

     

     

     

     

     

     

     

            public BearingSubcomponent()

     

            {}

     

     

            public BearingSubcomponent(string subcomponentName, ObservableCollection<SubcomponentItem> subcomponentItems)

     

            {

                    GetGraphDataPoints(subcomponentName, subcomponentItems);

            }

     

     

     

     

     

     

     

    }

     

     

     

    3.  Template for the PanelBar:
    --------------------------------------

     

     

     

     

    <HierarchicalDataTemplate x:Key="radPanelBarHierarchicalDataDataTemplate" ItemsSource="{Binding SubcomponentCollection}">

     

     

     

     

            <Border Margin="3" BorderThickness="1" BorderBrush="Transparent" CornerRadius="4">

     

     

     

     

                    <Grid Margin="2">

     

     

     

     

                            <Grid.ColumnDefinitions>

     

     

     

     

                                    <ColumnDefinition Width="*"/>

     

     

     

     

                                    <ColumnDefinition Width="Auto"/>

     

     

     

     

                            </Grid.ColumnDefinitions>

     

     

     

     

                            <TextBlock Grid.Column="1" FontWeight="Bold" Text="{Binding Path=CategoryName}" />

     

     

     

     

                </Grid>

     

     

     

     

            </Border>

     

     

     

     

            <HierarchicalDataTemplate.ItemTemplate>

     

     

     

     

                    <DataTemplate>

     

     

     

     

                            <TextBlock Grid.Row="1" FontWeight="Bold" Text="{Binding Path=SubcomponentName}"/>

     

     

     

     

                    </DataTemplate>

     

     

     

     

            </HierarchicalDataTemplate.ItemTemplate>

     

     

     

     

    </HierarchicalDataTemplate>


    4.  DataTemplates for ListBox:
    --------------------------------------

     

    <

     

    DataTemplate DataType="{x:Type modl:BearingSubcomponent}">

     

     

     

     

     

     

     

     

            <Grid >

     

     

     

     

     

     

     

     

                    <telerik:RadChart x:Name="bearing" Width="299" Height="299" ItemsSource="{Binding ConditionIndicatorDataPoints}">

     

     

     

     

     

     

     

     

                             <telerik:RadChart.DefaultView>

     

     

     

     

     

     

     

     

                                     <telerik:ChartDefaultView>

     

     

     

     

     

     

     

     

                                             <telerik:ChartDefaultView.ChartTitle>

     

     

     

     

     

     

     

     

                                                      <telerik:ChartTitle Content="{Binding Path=ChartName}" />

     

     

     

     

     

     

     

     

                                             </telerik:ChartDefaultView.ChartTitle>

     

     

     

     

     

     

     

     

                                             <telerik:ChartDefaultView.ChartLegend>

     

     

     

     

     

     

     

     

                                                      <telerik:ChartLegend Header="BEARING"/>

     

     

     

     

     

     

     

     

                                              </telerik:ChartDefaultView.ChartLegend>

     

     

     

     

     

     

     

     

                                              <telerik:ChartDefaultView.ChartArea>

     

     

     

     

     

     

     

     

                                                        <telerik:ChartArea >

     

     

     

     

     

     

     

     

                                                               <telerik:ChartArea.AxisY>

     

     

     

     

     

     

     

     

                                                                       <telerik:AxisY Title="GDF"/>

     

     

     

     

     

     

     

     

                                                               </telerik:ChartArea.AxisY>

     

     

     

     

     

     

     

     

                                                               <telerik:ChartArea.AxisX>

     

     

     

     

     

     

     

     

                                                                       <telerik:AxisX Title="OPTIME"/>

     

     

     

     

     

     

     

     

                                                               </telerik:ChartArea.AxisX>

     

     

     

     

     

     

     

     

                                                       </telerik:ChartArea>

     

     

     

     

     

     

     

     

                                            </telerik:ChartDefaultView.ChartArea>

     

     

     

     

     

     

     

     

                                   </telerik:ChartDefaultView>

     

     

     

     

     

     

     

     

                           </telerik:RadChart.DefaultView>

     

     

     

     

     

     

     

     

                           <telerik:RadChart.SeriesMappings>

     

     

     

     

     

     

     

     

                                    <telerik:SeriesMapping>

     

     

     

     

     

     

     

     

                                              <telerik:SeriesMapping.SeriesDefinition>

     

     

     

     

     

     

     

     

                                                        <telerik:LineSeriesDefinition />

     

     

     

     

     

     

     

     

                                              </telerik:SeriesMapping.SeriesDefinition>

     

     

     

     

     

     

     

     

                                              <telerik:SeriesMapping.ItemMappings>

     

     

     

     

     

     

     

     

                                                        <telerik:ItemMapping DataPointMember="YValue" FieldName="YPlotPoint" />

     

     

     

     

     

     

     

     

                                              </telerik:SeriesMapping.ItemMappings>

     

     

     

     

     

     

     

     

                                   </telerik:SeriesMapping>

     

     

     

     

     

     

     

     

                         </telerik:RadChart.SeriesMappings>

     

     

     

     

     

     

     

     

                </telerik:RadChart>

     

     

     

     

     

     

     

     

        </Grid>

     

     

     

     

     

     

     

     

    </DataTemplate>

     

     

     

     

     

    5.  Style for ListBox:
    -------------------------

     

    <

     

     

    Style x:Key="conditionIndicatorItemControlTemplate" TargetType="{x:Type ListBox}">

     

     

     

     

            <Setter Property="IsSynchronizedWithCurrentItem" Value="True" />

     

     

     

     

            <Setter Property="Template">

     

     

     

     

            <Setter Property="ItemsPanel">

     

     

     

     

            <Setter.Value>

     

     

     

     

                    <ItemsPanelTemplate>

     

     

     

     

                            <WrapPanel></WrapPanel>

     

     

     

     

                    </ItemsPanelTemplate>

     

     

     

     

           </Setter.Value>

     

     

     

     

    </Style>

     

     

     

     

    6.   Content of my 'Window1.xaml file':
    -----------------------------------------------

     

    <

     

    Grid>

     

     

     

     

            <Grid.RowDefinitions>

     

     

     

     

                    <RowDefinition Height="Auto"/>

     

     

     

     

                    <RowDefinition Height="*"/>

     

     

     

     

            </Grid.RowDefinitions>

     

     

     

     

            <TextBlock Grid.Row="0" Text="TITLE BAR" Background="#FFBDB7A9"/>

     

     

     

     

            <Grid Grid.Row="1">

     

     

     

     

                      <Grid.ColumnDefinitions>

     

     

     

     

                                <ColumnDefinition Width="0.7*"/>

     

     

     

     

                                <ColumnDefinition Width="3*"/>

     

     

     

     

                      </Grid.ColumnDefinitions>

     

     

     

     

                       <telerik:RadPanelBar x:Name="subcomponentCategories" Grid.Column="0" 
                                                         BorderThickness
    ="1" BorderBrush="#9098A3" Background="#FFBDB7A9"

     

     

     

     

                                                         ItemsSource="{Binding Path=MechanicalDiagnosticCategories}"

     

     

     

     

                                                         ItemTemplate="{StaticResource radPanelBarHierarchicalDataDataTemplate}">

     

     

     

     

                        </telerik:RadPanelBar>

     

     

     

     

     

     

     

     

     

                        <Grid Grid.Column="1" >

     

     

     

     

                                  <Border>

     

     

     

     

                                        <ListBox x:Name="conditionIndicatorItemControl"

     

     

     

     

                                                       HorizontalAlignment="Left"

     

     

     

     

                                                       VerticalAlignment="Top"

     

     

     

     

                                                       ScrollViewer.HorizontalScrollBarVisibility="Visible"

     

     

     

     

                                                       ScrollViewer.VerticalScrollBarVisibility="Visible"

     

     

     

     

                                                       Background="Blue"

     

     

     

     

                                                       Style="{DynamicResource conditionIndicatorItemControlTemplate}"

     

     

     

     

                                                       ItemsSource="{Binding ElementName=subcomponentCategories, Path=SelectedItem.SubcomponentItems}"

     

     

     

     

                                                      SnapsToDevicePixels="True">

     

     

     

     

                                         </ListBox>

     

     

     

     

                             </Border>

     

     

     

     

                      </Grid>

     

     

     

     

             </Grid>

     

     

     

     

    </Grid>

     

     

     

     

     

     

     

     

     

     

     

     

    7.  The content of my 'Window1.xaml.cs' file:
    ------------------------------------------------------

     

     

     

     

     

     

     

     

     

    public partial class Window1 : Window

     

     

     

     

    {

     

     

     

            public Window1()

     

            {

                    InitializeComponent();

                   

     

     DataContext = new AirMechViewModel();
            }

     

     

    }

     

     

  4. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 18 Aug 2009 Link to this post

    Hi Patrick Fletcher,

    Unfortunately we were unable to compile the pasted code locally. Either the formatting coruppted the snippets or some parts are missing in the first place but we are getting errors about missing template for the ListBox in XAML, and in code --  "The name 'subcomponentConstantsCollection' does not exist in the current context", "The name 'current' does not exist in the current context".

    We would ask you to open a formal support ticket and send us a runnable version of your application (file attachments are not allowed in the public forums) so we can advise you properly how to proceed. We apologize for the additional roundtrip necessary to resolve this issue.


    All the best,
    Manuel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Patrick Fletcher
    Patrick Fletcher avatar
    19 posts
    Member since:
    Jun 2009

    Posted 18 Aug 2009 Link to this post

    I am sorry, but I can not send you the source code of my company product.  I outline to you the structure of the collection, and send you the part of the code that is causing a problem.  I also outline to you what that problem is.  it is up to you to create a collection with the same structure I sent you and the same property names, and to create the necessary '.xaml' and '.xaml.cs'  file and copy and paste the xaml code I sent you in the xaml file, and the one line of datacontext code I sent you in the constructor of the '.xaml.cs' file associate with the xaml file. You also need to include all namespace and assembly references.  To replicate this problem requires that you pay attention and not only copy things verbatim,  I am not here to teach you WPF.   The WPF RadControl help information that is offer on your website and/or 'CHM' file is very terse and is of no help and use to us here at Sikorsky.  We at Sikorsky would like a solution to this problem and the sooner the better.
  6. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 19 Aug 2009 Link to this post

    Hi Patrick Fletcher,

    We are sorry for the misunderstanding -- it seemed you provided the source code in order to replicate exactly the scenario you are working on (as our original sample application did not help in resolving the issue) and that is why we asked if you could provide us with a runnable version of the same code.

    Nevertheless, on further testing we were able to reproduce the problem in our local tests as well and unfortunately we must confirm it is a bug within the chart control. Unfortunately we cannot suggest you a workaround at the moment but we have discussed this issue with our developers and it will be fixed for the weekly internal build scheduled for Friday.

    We are sorry for the temporary inconvenience. We have also updated your Telerik points for the report.


    Greetings,
    Manuel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. Patrick Fletcher
    Patrick Fletcher avatar
    19 posts
    Member since:
    Jun 2009

    Posted 24 Aug 2009 Link to this post

    We here at Sikorsky would like to take the time to thank Telerik for its serious and professional response in putting in a bug fix in its latest internal build, 821, that allows us here at Sikorsky to move our development forward again.  Thank you!
Back to Top