This is a migrated thread and some comments may be shown as answers.

ScheduleView not rendering contents?

1 Answer 118 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Guga
Top achievements
Rank 1
Guga asked on 29 May 2012, 02:51 PM
Hi guys,

Maybe I am just doing something wrong, but I have lost a lot of time on this already and have no idea what is going on.

I basically have a RadScheduleView Control inside of a Grid on a UserControl. This control is then placed inside of a Grid on a Window. Pretty simple and working perfectly.

My UserControl:
 
<UserControl x:Class="MonitoringRounds"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:EScIS.Win.Controls.MonitoringRounds"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             mc:Ignorable="d"
             d:DesignHeight="600" d:DesignWidth="1000" >
    <UserControl.DataContext>
        <local:MonitoringRoundsViewModel/>
    </UserControl.DataContext>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="0.05*" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <TextBlock Grid.Row="0">Monitoring Rounds</TextBlock>
        <telerik:RadScheduleView Grid.Row="1" Name="radsvMonitoringRounds" Padding="5" MaxHeight="400" MaxWidth="600" AppointmentsSource="{Binding Appointments}" ResourceTypesSource="{Binding ResourcesTypes}">
            <telerik:RadScheduleView.ViewDefinitions>
                <telerik:MonthViewDefinition />
                <telerik:TimelineViewDefinition />
            </telerik:RadScheduleView.ViewDefinitions>
        </telerik:RadScheduleView>
    </Grid>
</UserControl>

My Window:

<Window x:Class="LSpecs"
    xmlns:menu="clr-namespace:EScIS.Win.LSpecs.UI.Controls.Menu;assembly=EScIS.Win.LSpecs.UI.Controls.Menu"
    xmlns:ma ="clr-namespace:EScIS.Win.Controls.MonitoringAssignees;assembly=EScIS.Win.Controls.MonitoringAssignees"
    xmlns:mp ="clr-namespace:EScIS.Win.Controls.MonitoringPrograms;assembly=EScIS.Win.Controls.MonitoringPrograms"
    xmlns:mr ="clr-namespace:EScIS.Win.Controls.MonitoringRounds;assembly=EScIS.Win.Controls.MonitoringRounds"
    Title="Desktop" Height="1200" Width="1900" WindowState="Maximized">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="40" />
            <RowDefinition />
            <RowDefinition Height="20"/>
        </Grid.RowDefinitions>
        <Border Grid.Row="0" Name="borderMainToolBar" BorderThickness="0,0,0,2" BorderBrush="Gray">
            <menu:MainToolbar Name="ctrlMainToolBar" menu:MainToolbar.Button_Click_WorkflowMenu="ctrlDesktop_Button_Click_WorkflowMenu"/>
        </Border>
        <menu:Desktop Grid.Row="1" Name="ctrlDesktop" 
                      menu:WorkflowFieldPreparation.Button_Click_MonitoringAssignees="Desktop_Button_Click_MonitoringAssignees"
                      menu:WorkflowFieldPreparation.Button_Click_MonitoringPrograms="ctrlDesktop_Button_Click_MonitoringPrograms"
                      menu:WorkflowFieldPreparation.Button_Click_MonitoringRounds="ctrlDesktop_Button_Click_MonitoringRounds"
                      />
        <ma:MonitoringAssignees  Grid.Row="1" Name="ctrlMonitoringAssignees" Visibility="Hidden"/>
        <mp:MonitoringPrograms  Grid.Row="1" Name="ctrlMonitoringPrograms" Visibility="Hidden"/>
        <mr:MonitoringRounds  Grid.Row="1" Name="ctrlMonitoringRounds" Visibility="Hidden"/>
    </Grid>
</Window>


On the code side of the story I am using a simplified MVVM pattern with a ViewModel supporting my control:

Imports EScIS.Database
Imports EScIS.MVVM.Base
Imports System.ComponentModel
Imports System.Collections.ObjectModel
Imports System.Windows.Data
Imports Telerik.Windows.Controls
Imports Telerik.Windows.Controls.ScheduleView
 
Public Class MonitoringRoundsViewModel
    Inherits EScIS.MVVM.Base.ViewModelBase
 
    Private _context As ESdatEntities
    Private _monitoringRounds As ObservableCollection(Of Monitoring_Rounds)
    Private _monitoringRoundsView As ICollectionView
    Private _monitoringPrograms As ObservableCollection(Of LSPECS_Monitoring_Programs)
    Private _monitoringProgramsView As ICollectionView
    Private _monitoringRoundsAssignedMonitoringPrograms As ObservableCollection(Of LSPECS_Monitoring_Round_Assigned_Monitoring_Programs)
    Private _monitoringRoundsAssignedMonitoringProgramsView As ICollectionView
 
    Private _appointments As ObservableCollection(Of Appointment)
    Private _resourcesTypes As ObservableCollection(Of ResourceType)
 
    Public Property MonitoringRoundsList() As ObservableCollection(Of Monitoring_Rounds)
        Get
            Return Me._monitoringRounds
        End Get
        Set(value As ObservableCollection(Of Monitoring_Rounds))
            Me._monitoringRounds = value
            Me.OnPropertyChanged("MonitoringRoundsList")
        End Set
    End Property
 
    Public Property MonitoringProgramsList() As ObservableCollection(Of LSPECS_Monitoring_Programs)
        Get
            Return Me._monitoringPrograms
        End Get
        Set(value As ObservableCollection(Of LSPECS_Monitoring_Programs))
            Me._monitoringPrograms = value
            Me.OnPropertyChanged("MonitoringProgramsList")
        End Set
    End Property
 
    Public Property MonitoringRoundsAssignedMonitoringProgramsList() As ObservableCollection(Of LSPECS_Monitoring_Round_Assigned_Monitoring_Programs)
        Get
            Return Me._monitoringRoundsAssignedMonitoringPrograms
        End Get
        Set(value As ObservableCollection(Of LSPECS_Monitoring_Round_Assigned_Monitoring_Programs))
            Me._monitoringRoundsAssignedMonitoringPrograms = value
            Me.OnPropertyChanged("MonitoringRoundsAssignedMonitoringProgramsList")
        End Set
    End Property
 
    Public Property Appointments() As ObservableCollection(Of Appointment)
        Get
            Return Me._appointments
        End Get
        Set(value As ObservableCollection(Of Appointment))
            Me._appointments = value
            Me.OnPropertyChanged("Appointments")
        End Set
    End Property
 
    Public Property ResourcesTypes() As ObservableCollection(Of ResourceType)
        Get
            Return Me._resourcesTypes
        End Get
        Set(value As ObservableCollection(Of ResourceType))
            Me._resourcesTypes = value
            Me.OnPropertyChanged("ResourcesTypes")
        End Set
    End Property
 
    Public Sub New()
        Me.Load(Nothing)
    End Sub
 
    Protected Overrides Sub Add(action As Object)
 
    End Sub
 
    Protected Overrides Sub Delete(action As Object)
 
    End Sub
 
    Protected Overrides Sub Edit(action As Object)
 
    End Sub
 
    Protected Overrides Sub Load(action As Object)
        LoadData()
        LoadCalendarData()
    End Sub
 
    Public Sub LoadControlData()
        Me.Load(Nothing)
    End Sub
 
    Private Sub LoadData()
        Try
            With Me._context
 
                Me._context = New ESdatEntities()
 
                Me.MonitoringRoundsList = New ObservableCollection(Of Monitoring_Rounds)(
                                        From mr In Me._context.Monitoring_Rounds
                                        Select mr)
                Me.MonitoringProgramsList = New ObservableCollection(Of LSPECS_Monitoring_Programs)(
                                        From mp In Me._context.LSPECS_Monitoring_Programs
                                        Select mp)
                Me.MonitoringRoundsAssignedMonitoringProgramsList = New ObservableCollection(Of LSPECS_Monitoring_Round_Assigned_Monitoring_Programs)(
                                        From mramp In Me._context.LSPECS_Monitoring_Round_Assigned_Monitoring_Programs
                                        Select mramp)
 
            End With
        Catch ex As Exception
            Debug.WriteLine(ex.Message)
            Throw New ApplicationException("Database Error: " & ex.Message)
        End Try
 
        Me._monitoringRoundsView = CollectionViewSource.GetDefaultView(Me.MonitoringRoundsList)
        Me._monitoringProgramsView = CollectionViewSource.GetDefaultView(Me.MonitoringProgramsList)
        Me._monitoringRoundsAssignedMonitoringProgramsView = CollectionViewSource.GetDefaultView(Me.MonitoringRoundsAssignedMonitoringProgramsList)
 
        Me.OnPropertyChanged("MonitoringRoundsList")
        Me.OnPropertyChanged("MonitoringProgramsList")
        Me.OnPropertyChanged("MonitoringRoundsAssignedMonitoringProgramsList")
    End Sub
 
    Private Sub LoadCalendarData()
        'GenerateResourcesFromMonitoringPrograms()
        'GenerateAppointmentsFromMonitoringPrograms()
        'GenerateAppointmentsFromMonitoringRounds()
        Me.ResourcesTypes = New ObservableCollection(Of ResourceType)
        Me.Appointments = New ObservableCollection(Of Appointment)
    End Sub
 
    Private Sub GenerateResourcesFromMonitoringPrograms()
        Me.ResourcesTypes = New ObservableCollection(Of ResourceType)
 
        'Add monitoring program resource type
        Dim mpType As New ResourceType("Monitoring Program")
 
        'Add monitoring programs as resources
        If Me._monitoringPrograms Is Nothing Then
            Return
        End If
 
        For Each mp In _monitoringPrograms
            Dim res As New Resource(mp.Monitoring_Program)
            mpType.Resources.Add(res)
        Next
 
        Me.ResourcesTypes.Add(mpType)
        Me.OnPropertyChanged("ResourcesTypes")
    End Sub
 
    Private Sub GenerateAppointmentsFromMonitoringPrograms()
        Me.Appointments = New ObservableCollection(Of Appointment)
 
        'Add monitoring programs as appointments
        If Me._monitoringPrograms Is Nothing Then
            Return
        End If
 
        For Each mp In _monitoringPrograms
            Dim app As New Appointment()
            app.Subject = mp.Monitoring_Program
            app.Start = mp.Start_Date
            app.End = If(mp.End_Date.HasValue, mp.End_Date, mp.Start_Date)
 
            Me.Appointments.Add(app)
        Next
 
        Me.OnPropertyChanged("Appointments")
    End Sub
 
    Private Sub GenerateAppointmentsFromMonitoringRounds()
        If Me.Appointments Is Nothing Then
            Me.Appointments = New ObservableCollection(Of Appointment)
        End If
 
        'Add MonitoringRounds as appointments
        If Me._monitoringRounds Is Nothing Then
            Return
        End If
 
        For Each mr In _monitoringRounds
            Dim app As New Appointment()
            app.Subject = mr.Monitoring_Round
            app.Start = mr.Start_Date
            app.End = If(mr.End_Date.HasValue, mr.End_Date, mr.Start_Date)
 
            Me.Appointments.Add(app)
        Next
 
        Me.OnPropertyChanged("Appointments")
    End Sub
 
    Public Overrides Sub Dispose()
        If Not Me.disposed Then
            Me._context.Dispose()
            Me.disposed = True
        End If
        MyBase.Dispose()
    End Sub
 
End Class

On the ViewModel behind the window I basically set the visibility of the control to visible when a user clicks on a button. All this works fine.

Also at the moment I am not even trying to add any Appointments. I commented that bit of the code out to eliminate sources of problems. All I want is the control to display properly with the default view and no appointments.

When the control is rendered in run time all the header/menu structure renders fine, but the content area is blank. See attached photo for image of this.

At design time it appears to be fine since it displays the usual "Please set an Appointments Source" message.

Any idea what might be causing this?

Using:
Visual Studio 2010
Targeting .NET Framework 4.0
Windows 7
Telerik.Windows.Controls.ScheduleView vs. 2012.1.326.40

Thanks for your help in advance.

1 Answer, 1 is accepted

Sort by
0
Guga
Top achievements
Rank 1
answered on 30 May 2012, 01:13 AM
Found the issue finally.

All because of a style defined somewhere in the resources:

<Style TargetType="{x:Type Grid}">
    <Setter Property="Background" Value="LightGray"/>
</Style>
Tags
ScheduleView
Asked by
Guga
Top achievements
Rank 1
Answers by
Guga
Top achievements
Rank 1
Share this question
or