Exception Blend

3 posts, 0 answers
  1. Steve Behrendt
    Steve Behrendt avatar
    12 posts
    Member since:
    Feb 2010

    Posted 04 Sep 2014 Link to this post

    Hi Telerik,

    I'm getting this exception (see below) when applying a custom style to a DatePicker in Blend. I'm clicking in Blend on the Control -> Edit Template -> Edit Current.

    In XAML I reference the telerik generics.xaml likes this:

    <Page.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="ms-appx:///Telerik.Universal.UI.Xaml.Input/Themes/ThemeResourcesDark.xaml"/>
                </ResourceDictionary.MergedDictionaries>

                <telerikDate:DisplayModeToVisibilityConverter x:Key="DisplayModeConverter" VisibleDisplayMode="Standard"/>
                .....

    And further down it created this ControlTemplate for me.

    <ControlTemplate x:Key="RadDatePickerControlTemplate1" TargetType="telerikInput:RadDatePicker">
                <Grid Background="{TemplateBinding Background}">
                <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <ContentControl  Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" Style="{TemplateBinding HeaderStyle}" IsTabStop="False"
                Visibility="{Binding DisplayMode, Converter={StaticResource DisplayModeConverter}, RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
                <telerikDate:DateTimePickerButton x:Name="PART_PickerButton" Grid.Row="1" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
                Visibility="{Binding DisplayMode, Converter={StaticResource DisplayModeConverter}, RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
                <Popup x:Name="PART_Popup" IsOpen="{TemplateBinding IsOpen}" IsLightDismissEnabled="True" >
                <Border x:Name="PART_SelectorLayoutRoot" Style="{TemplateBinding SelectorBackgroundStyle}">
                <Grid>
                <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <ContentPresenter x:Name="PART_SelectorHeader" Content="{TemplateBinding SelectorHeader}" ContentTemplate="{TemplateBinding SelectorHeaderTemplate}"/>
                <Grid HorizontalAlignment="Center" Grid.Row="1">
                <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <telerikDate:DateTimeList x:Name="PART_MonthList" ComponentType="Month"
                ItemWidth="{TemplateBinding ItemLength}" 
                ItemHeight="{TemplateBinding ItemLength}" 
                ItemSpacing="{TemplateBinding ItemSpacing}"/>
                <telerikDate:DateTimeList x:Name="PART_DayList" ComponentType="Day" Grid.Column="1"
                ItemWidth="{TemplateBinding ItemLength}" 
                ItemHeight="{TemplateBinding ItemLength}" 
                ItemSpacing="{TemplateBinding ItemSpacing}"/>
                <telerikDate:DateTimeList x:Name="PART_YearList" ComponentType="Year" Grid.Column="2"
                ItemWidth="{TemplateBinding ItemLength}" 
                ItemHeight="{TemplateBinding ItemLength}" 
                ItemSpacing="{TemplateBinding ItemSpacing}"/>
                </Grid>

                <telerikDate:CommandBarInfo x:Name="PART_CommandBarInfo">
                <telerikDate:CommandBarInfo.PickerCommandBar>
                <CommandBar>
                <AppBarButton Icon="Accept" x:Name="PART_CommandBarOKButton" />
                <AppBarButton Icon="Cancel" x:Name="PART_CommandBarCancelButton" />
                </CommandBar>
                </telerikDate:CommandBarInfo.PickerCommandBar>
                </telerikDate:CommandBarInfo>
                </Grid>
                </Border>
                </Popup>
                </Grid>
                </ControlTemplate>

            </ResourceDictionary>
        </Page.Resources>


    I reference that ControleTemplate likes this: 
    <telerikInput:RadDatePicker Grid.Column="1" DisplayValueFormat="dd MMM, yyyy" Value="{Binding Item.Date, Mode=TwoWay}" Template="{StaticResource RadDatePickerControlTemplate1}"/>



    ArgumentException: Delegate to an instance method cannot have null 'this'.

    at System.MulticastDelegate.ThrowNullThisInDelegateToInstance()
       at Telerik.Universal.UI.Xaml.Controls.Input.DateTimePicker.UnhookCoreWindowEvents()
       at Telerik.Universal.UI.Xaml.Controls.Input.DateTimePicker.UnapplyTemplateCore()
       at Telerik.Universal.UI.Xaml.Controls.RadControl.OnApplyTemplate()
       at Windows.UI.Xaml.UIElement.Measure(Size availableSize)
       at Microsoft.Expression.WindowsXamlPhonePlatform.InstanceBuilders.DesignMarginHelper.MeasureOverride(IDesignMarginRoot designMarginRoot, UIElement child, Size availableSize)
       at Microsoft.Expression.WindowsXamlPhonePlatform.InstanceBuilders.PageStandIn.MeasureOverride(Size availableSize)
       at Windows.UI.Xaml.UIElement.UpdateLayout()
       at Microsoft.Expression.WindowsXamlPlatform.Views.WindowsUIXamlImageHost.WindowsXamlSceneWrapper.UpdateLayout()
       at Microsoft.Expression.WindowsXamlPlatform.Views.WindowsUIXamlImageHost.Render(BitmapWrapper bitmapWrapper, Boolean isNewBitmapWrapper, Boolean timerTick)
       at Microsoft.Expression.Platform.Views.ImageHost.ImageHostBitmapContentPresenter.Redraw(Boolean force, Boolean timerTick)
       at Microsoft.Expression.Platform.Views.ImageHost.<Redraw>b__0()
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
  2. Steve Behrendt
    Steve Behrendt avatar
    12 posts
    Member since:
    Feb 2010

    Posted 04 Sep 2014 in reply to Steve Behrendt Link to this post

    I'm getting the same exception in Visual Studio as well.

    I had to reference the generics.xaml manually otherwise the Edit Template -> Edit a copy - option wouldn't work. 

    Is that by design?

    Thanks a lot in advance!
    Steve
  3. Rosy Topchiyska
    Admin
    Rosy Topchiyska avatar
    550 posts

    Posted 09 Sep 2014 Link to this post

    Hello Steve,

    Thank you for contacting us.

    As far as I can see, this exception is thrown by the Designer in the WP project only when the CommandBar in the ContentTemplate of the picker is selected and does affect the control runtime.

    For demonstration I have attached a sample Windows Universal application where I have added the ControlTemplate of the RadDatePicker. In App.xaml are the resource dictionary needed to resolve the Telerik named resources and the common resources. In MainPage.xaml of the projects I have added the ControlTemplate of the RadDateTimePicker as a static resource in the Page.Resources.

    At this moment it is not possible to extract the style of a RadDate/TimePicker control, but we will fix this issue in the future versions of the product.

    I hope this helps. Please, let us know if you have further questions. 

    Regards,
    Rosy Topchiyska
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top