We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Simple application running

Hello all, I'm fairly new to MVVM. I can run the demonstration project, and I'm trying to create my own simple chart. I cannot figure out why my chart isn't doing anything - when I run my application nothing is displayed, I cannot see the chart, despite in the designer the selectable bounding box appearing in the center of the page. Below is my code:

MainPage.xaml:

<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:SyncTest"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Charts="using:Syncfusion.UI.Xaml.Charts"
    x:Class="SyncTest.MainPage"
    mc:Ignorable="d">

    <Grid Background="Wheat">
        <Page DataContext="UsersViewModel" />


        <Charts:SfChart HorizontalAlignment="Left" Height="449" Margin="194,139,0,0" VerticalAlignment="Top" Width="949" x:Name="test">

            <Charts:LineSeries

                ItemsSource="{Binding UsersList}"

                XBindingPath="TimeStamp"

                YBindingPath="NoOfUsers">

            </Charts:LineSeries>
        </Charts:SfChart>


    </Grid>
</Page>


Code behind (MainPage.xaml.cs)

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

using System.Collections;
using System.Collections.ObjectModel;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace SyncTest
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        UsersViewModel uvm;
        public MainPage()
        {
            this.InitializeComponent();
            uvm = new UsersViewModel();
            test.Series[0].ItemsSource = uvm.UsersList;
        }
    }

    public class UserProfile
    {
        public DateTime TimeStamp { get; set; }

        public double NoOfUsers { get; set; }
    }

    public class UsersViewModel
    {
        public UsersViewModel()
        {
            this.UsersList = new ObservableCollection<UserProfile>();
            DateTime date = DateTime.Today;
            UsersList.Add(new UserProfile
            {
                TimeStamp = date.AddHours(0.5),
                NoOfUsers = 1000
            });
            UsersList.Add(new UserProfile
            {
                TimeStamp = date.AddHours(1),
                NoOfUsers = 5000
            });
            UsersList.Add(new UserProfile
            {
                TimeStamp = date.AddHours(1.5),
                NoOfUsers = 3000
            });
            UsersList.Add(new UserProfile
            {
                TimeStamp = date.AddHours(2),
                NoOfUsers = 4000
            });
            UsersList.Add(new UserProfile
            {
                TimeStamp = date.AddHours(2.5),
                NoOfUsers = 2000
            });
            UsersList.Add(new UserProfile
            {
                TimeStamp = date.AddHours(3),
                NoOfUsers = 1000
            });
        }
        public ObservableCollection<UserProfile> UsersList
        {
            get;
            set;
        }
    }
}


I have also tried again, this time following http://help.syncfusion.com/UG/winrt/default.htm#!Documents/lineseries.htm, but no luck

Am I missing some kind of initialiser out? 

Thanks


2 Replies

TO Tom June 4, 2014 11:44 AM UTC

Please delete the above, I posted prematurely and cannot find an edit button!


MA Mohammed Azarudeen Syncfusion Team June 5, 2014 12:10 PM UTC

Hi Tom,

 

Thanks for contacting Syncfusion support.

 

As this is duplicate query of 116518 (http://www.syncfusion.com/support/forums/winrt/chart/116518) forum, Please refer forum 116518 for more details on this query.

 

Regards,

Mohammed Azarudeen.


Loader.
Live Chat Icon For mobile
Up arrow icon