Sales Dashboard - Making Regions Work

13 posts, 0 answers
  1. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 16 Jun 2011 Link to this post

    Hi all,

    Extreme newbie here trying to use the Sales Dashboard project (I have downloaded the source code) to help me build my own dashboard project.

    I have basically created the "Shell" application, the "Common" application and one module (the ListBox used to select a salesperson) built. When I run the Shell project I get an error on the InitializeComponent call:

    Set property 'Microsoft.Practices.Composite.Presentation.Regions.RegionManager.RegionName' threw an exception. [Line: 84 Position: 67]

    Inner Exception:

        {System.NullReferenceException: Object reference not set to an instance of an object." & vbCrLf & "   at Microsoft.Practices.ServiceLocation.ServiceLocator.get_Current()" & vbCrLf & "   at Microsoft.Practices.Composite.Presentation.Regions.RegionManager.CreateRegion(DependencyObject element)" & vbCrLf & "   at Microsoft.Practices.Composite.Presentation.Regions.RegionManager.OnSetRegionNameCallback(DependencyObject element, DependencyPropertyChangedEventArgs args)" & vbCrLf & "   at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)" & vbCrLf & "   at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)" & vbCrLf & "   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)" & vbCrLf & "   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)" & vbCrLf & "   at Microsoft.Practices.Composite.Presentation.Regions.RegionManager.SetRegionName(DependencyObject regionTarget, String regionName)}

    Message: Object reference not set to an instance of an object.

    I really don't even understand how these regions work but I have tried to follow the Sales Dashboard example as closely as I can and I don't see what I'm missing. Anyone have any ideas?

    Thanks!!
  2. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 16 Jun 2011 Link to this post

    Not sure if this was it but I did not have the Bootstrapper class in my "Shell" application. I am working with vb.net so I added the class and then under the app.xaml code the sales dashboard has this:

     

     

    private void Application_Startup(object sender, StartupEventArgs e)

     

    {

     

     

    new Bootstrapper().Run();

     

    }


    The problem is converting this line to vb.net, nothing I am trying seems to work.

    Thanks again!
  3. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 16 Jun 2011 Link to this post

    I think I have the "bootstrapper" issue resolved with this code:

     

     

    Dim lBootstrapper As New Bootstrapper

     

    lBootstrapper.Run()

    So now I believe I am getting somewhere...I'm not sure where but at least I have a different error now:

    An exception occurred while initializing module 'ProvidersModule'. (Corresponds to RepresentativesModule)
        - The exception message was: An exception has occurred while trying to add a view to region 'RepresentativesRegion'.
        - The most likely causing exception was was: 'System.Windows.Markup.XamlParseException: No matching constructor found on type 'MyCompany.Silverlight.Controls.ProvidersViewModel'. [Line: 10]



    So it is insisting upon having a parameterless constructor on the ProvidersViewModel'(Corresponds to RepresentativesViewModel in the example). Here is the code for the ProvidersViewModel:

    #Region "Imports"
    Imports System.ComponentModel
    Imports Microsoft.Practices.Composite.Events
    Imports System.Collections.ObjectModel   
    #End Region
      
    Public Class ProvidersViewModel
        Implements INotifyPropertyChanged 
      
    #Region "Private Fields"
      
        Private _tinNumber As String = String.Empty
        Private _selectedProvider As IProvider
      
        Private _eventAggrigator As IEventAggregator
        Private _serviceProxy As IProviderDashboardServiceProxy
      
    #End Region
      
    #Region "Public Events"
      
        Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
      
    #End Region
      
    #Region "Public Properties"
      
        Public Property SelectedProvider As IProvider
            Get
                Return _selectedProvider
            End Get
            Set(ByVal value As IProvider)
                _selectedProvider = value
                OnPropertyChanged("SelectedProvider")
                _eventAggrigator.GetEvent(Of ProviderChangedEvent)().Publish(value)
            End Set
        End Property
      
      
    #End Region
      
    #Region "Constructor"
      
        Public Sub New(ByVal eventAggrigator As IEventAggregator, ByVal serviceProxy As IProviderDashboardServiceProxy)
      
            _eventAggrigator = eventAggrigator
            _serviceProxy = serviceProxy
            Providers = New ObservableCollection(Of IProvider)
            LoadProviders()
      
        End Sub
      
    #End Region
      
    #Region "Providers Data Retrieval Methods"
      
        Private Sub LoadProviders()
      
            Dim lProviders As List(Of Dictionary(Of String, String))
            Dim lProvidersList As New List(Of IProvider)
      
            lProviders = _serviceProxy.GetSubTinsForTinNum(_tinNumber, False)
      
            For Each lProvider As Dictionary(Of String, String) In lProviders
      
                lProvidersList.Add(New IProvider With {.SubTinSequenceNumber=lProvider("SUB_TIN_SEQ_NUM").ToString.Trim, .Name=lProvider("NAME").ToString.Trim})
      
            Next
      
            For Each lProvider As IProvider In lProvidersList
      
                Providers.Add(lProvider)
      
            Next
      
            SelectedProvider = Providers(0)
      
        End Sub  
    #End Region
      
    #Region "INotifyPropertyChanged Implementation"
      
        Protected Overridable Sub OnPropertyChanged(ByVal propertyName As String)
            RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName))
        End Sub
      
        Public Property Providers As ObservableCollection(Of IProvider)   
      
    #End Region  
      
    End Class

    The error is occurring in the App.xaml.vb code right after the lBootstrapper.Run() line. The code makes it all the way through the bootstrapper, but then throws this error.

    Also i'm struggling to understand how in the Representatives module, in the RepresentativesView constructor, how the RepresentativesViewModel is being passed. If someone could help me understand that it would also be great.  

    Thank you in advance!!

  4. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 16 Jun 2011 Link to this post

    Still making headway...

    I got around the previous issue by declaring the DataContext in the xaml. Now I am getting stuck on the service proxies.

    In the file RepresentativesViewModel.cs, in order to load the employees this line of code is used (within the LoadRegions method):

    this.serviceProxy.GetRepresentatives(regions, LoadEmployees);

    The LoadEmployees method looks like this:

    private void LoadEmployees(List<IEmployee> reps)
            {
                foreach (IEmployee rep in reps)
                {
                    this.RepresentativesStorage.Add(rep);
                    // On first load display all reps
                    Representatives.Add(rep);
                }
                // On first load select the first rep in the list
                this.SelectedRepresentative = this.Representatives[0];
            }

    There are a couple things I don't understand here:

        1) The LoadEmployees method takes a parameter, reps which is a List(Of IEmployee), but it isn't being passed...how? When I do the same code in VB I get an error telling me that "Argument not specified..."

        2) In VB, the LoadEmployees method must be a function or I get the error "Expression does not produce a value"

    I feel like I am getting closer, but still not quite there because I just don't understand how some of these things are working. Once again, any help is appreciated.

    Thanks!

  5. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 22 Jun 2011 Link to this post

    Hi Joe,

    Sorry for the delayed reply. Are you trying to port the SalesDashboard to VB? Currently we don't offer a VB version of the SalesDashboard. I'd advice you to either use our VB Converter or try InstantVB. Let me know how it goes.

    Greetings,
    Kiril Stanoev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 27 Jun 2011 Link to this post

    Thank you!

    I'm trying to use it as an example while creating my own dashboard in vb.net. I have used your code converter heavily but some things just don't translate correctly. In any case I have gotten around this issue and am now struggling with how to pass parameters from one control to the other (for instance if the sales dashboard was tied into a website where different companies logged in, the company ID would need to be passed to the application from the .aspx page which in turn would need to pass it to the salesperson selector). I can get it in from the .aspx page no problem but then passing it on to the control where the salespeople are selected is where i'm running into a wall.
  7. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 28 Jun 2011 Link to this post

    Hello Joe,

    Let me give you a quick advice while you're still in a beginning stage. The Sales Dashboard demo is pretty old and was built around the time when the transition between Silverlight 2 and 3 happened. The ideas and approaches in this demo are quite outdated and many workarounds were used to bring it to the current state. That's why I don't think that the Sales Dashboard demos is the most appropriate resource to learn from. In addition, with our official Q2 2011 release (scheduled for the second half of July) we will drop the support for it. Since Sales Dashboard's last update there have been many improvements in the Silverlight plugin as well as in our controls.

    My advice is to take a look at our brand new dashboard demo - Telerik Executive Dashboard. This demo was built with all the best practices in mind and it is the perfect resource to learn from. I'd recommend you use the Executive Dashboard demo as a reference before you dig any deeper in the Sales Dashboard. It will save you both time and effort.

    You can download the source code of the Telerik Executive Dashboard from you Telerik account. Have a look at it and contact us as soon as possible. We'd be glad to further assist you with any inquires you might have.

    Greetings,
    Kiril Stanoev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 28 Jun 2011 Link to this post

    Thank you very much for the information, I wasn't aware that the sales dashboard was so outdated. I think I will take your advice and stop using it as a reference and take a look at the new dashboard, I don't want to be learning bad habits and definitely want to be learning from a project that is using best practices. I wish I would have stumbled upon this information about a month ago though since I am so deep into the sales dashboard, but better late than never!

    I'll take a look and reply back.

    Thanks again!
  9. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 28 Jun 2011 Link to this post

    Downloaded the source code and the project won't load due to the attached error. Something about expressions blend?
  10. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 28 Jun 2011 Link to this post

    Okay i've gotten the executive dashboard project up and running and I honestly think that I need to just stick with what I was doing, I am way too far in to just start over and the sales dashboard is a much better fit for what I am actually trying to do.

    All I really need to figure out now is how to capture the event of the salesperson changed in the other controls (modules). When I convert the code to VB, it doesn't work. If someone could simply give me an example of how when the salesperson is changed that event gets caught by the other modules that need the salesperson ID in VB.net that would be a huge help and I THINK the last major hurdle I need to get over. I don't need the entire project converted, I just need to know how to make the event handling work in VB.net.

    Thanks again!
  11. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 29 Jun 2011 Link to this post

    Okay, so I'm trying to combine the approaches from the executive dashboard into the sales dashboard. Instead of using different assemblies for each control and trying to use the regions I am just creating the content in the MainPage.xaml like the executive dashboard does. This does make getting the data back and forth between controls much easier and everything is working great. My only problem is that once I stop using regions, I lose all that nice formatting that is in the sales dashboard (DashboardControl.xaml which is a content control).

    So my question now is simply how do I apply the formatting to the MainPage.xaml so that the nice labels and background for each region is displayed?

    Thanks!
  12. Kalin Milanov
    Admin
    Kalin Milanov avatar
    447 posts

    Posted 04 Jul 2011 Link to this post

    Hello Jfkrueger,

    At this point I fear the conversation is becoming too abstract. Could you please send us your project so we can have a look and provide you with the help you need.

    Thanks in advance.

    Greetings,
    Kalin Milanov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  13. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 05 Jul 2011 Link to this post

    I was just trying to figure out how the formatting was applied to the individual sections in the dashboard. I figured it out and researched templates and have it working just fine. Thanks. If I have any other issues I will just open a new question. Thanks again for all of your help.
Back to Top