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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Binding Calendar to DataTemplate

Thread ID:

Created:

Updated:

Platform:

Replies:

107290 Feb 23,2013 04:23 AM UTC May 28,2014 02:24 PM UTC WinRT 4
loading
Tags: SfCalendar
Michael Sherburne
Asked On February 23, 2013 04:23 AM UTC

I'm currently using the samples for WinRT controls and trying prove out some concepts on a project of mine.  I want to do something similar to the AppointmentsDemo and can't seem to get my DataContext to bind to the DataTemplate.  I'm using the MVVM pattern and can bind everything else.  Even when I mimic the examples exactly I get a null value in the ConverterParameter for the CellTemplate.

        <DataTemplate x:Key="CellTemplate">
            <Grid>
                <TextBlock Text="{Binding Converter={StaticResource CellConverter}, ConverterParameter={Binding TempData}}"
                               VerticalAlignment="Top" HorizontalAlignment="Right"
                               Margin="3" FontSize="8" TextWrapping="Wrap" />
                <TextBlock Text="{Binding Day}"
                               VerticalAlignment="Bottom"
                               Margin="3" />
            </Grid>
        </DataTemplate>

Karthikeyan L [Syncfusion]
Replied On February 25, 2013 11:36 AM UTC

Hi Michael,

We cannot bind the member to the ConvertParameter since it is not a dependency property. We have prepared a sample based on your requirement by passing the collection as resource to ConvertParameter. We have attached the sample for your reference.

Could you please check the attached sample and let us know whether the sample meet the requirement.

[Sample link]: http://www.syncfusion.com/downloads/Support/DirectTrac/General/Calender_Demo-1491579611.zip

Please let us know if you have any concerns.

Regards,
Karthikeyan L.

Michael Sherburne
Replied On March 9, 2013 05:48 PM UTC

That's essentially what I had to do.  I was getting hung up on trying to pull data from my ViewModel.  For anyone who is curious here is my code sample.

        <!-- Data Resources -->
        <Data:TaskItemData x:Key="TaskItemData" />

        <DataTemplate x:Key="CellTemplate">
            <Grid>
                <TextBlock Text="{Binding Date, Converter={StaticResource CellConverter}, ConverterParameter={StaticResource TaskItemData}}"
                       VerticalAlignment="Top" HorizontalAlignment="Right"
                       Margin="3" FontSize="5" TextWrapping="Wrap"/>
                <TextBlock Text="{Binding Day}"
                       VerticalAlignment="Bottom"
                       Margin="3"/>
            </Grid>
    </DataTemplate>

        public TaskItemData()
        {
            ViewModel.ViewModelLocator locator = App.Current.Resources["Locator"] as ViewModel.ViewModelLocator;

            if (locator != null)
            {
                List<TaskViewModel> tasks = locator.Main.Tasks;
                this.AddRange(tasks);
            }           
        }

Karthikeyan L [Syncfusion]
Replied On March 11, 2013 01:26 PM UTC

Hi Michael,

Based on your code snippet, we have prepared a sample and we have attached the sample for your reference. Please check the sample and let us know the sample meet your requirement, otherwise please provide some information regarding the problem you are facing.

[Sample link]: http://www.syncfusion.com/downloads/Support/DirectTrac/General/Calender_Demo1014616385.zip

Please let us know if you have any queries.

Regards,
Karthikeyan.


Imran Prasla
Replied On May 28, 2014 02:24 PM UTC

My case is somewhat similar to the ones above. What I am trying to achieve is there is a service/api that I call in order to get what events fall on what day and based on that I bind the data to the calendar. The above scenarios doesn't work because the calendar gets initialized before the service request is completed. Therefore, it is always blank events. My viewmodel calls the service and viewmodel binds to any control via the code behind file. Let me know if there is a better way to achieve this problem.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;