Unspecified error on DataBoundListBox for Mango

2 posts, 0 answers
  1. Pieter
    Pieter avatar
    6 posts
    Member since:
    Jul 2011

    Posted 28 Aug 2011 Link to this post

    Hi,

    I'm converting my project to WP7.1. I already update the Telerik references to Mango package, but I'm getting the error below when I try to view a pivot with a DataBoundListBox:

       at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at Telerik.Windows.Controls.RadVirtualizingDataControl.em(RadVirtualizingDataControlItem A_0)
       at Telerik.Windows.Controls.RadVirtualizingDataControl.eo(IDataSourceItem A_0, Int32 A_1)
       at Telerik.Windows.Controls.RadVirtualizingDataControl.ex(IDataSourceItem A_0, Boolean A_1)
       at Telerik.Windows.Controls.RadVirtualizingDataControl.cw(Boolean A_0)
       at Telerik.Windows.Controls.RadVirtualizingDataControl.ManageViewport()
       at Telerik.Windows.Controls.RadVirtualizingDataControl.BalanceVisualSpace()
       at Telerik.Windows.Controls.RadVirtualizingDataControl.OnLoaded(Object sender, RoutedEventArgs e)
       at Telerik.Windows.Controls.RadDataBoundListBox.OnLoaded(Object sender, RoutedEventArgs e)
       at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
       at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)

    I declare pivot template as below:
    <DataTemplate x:Key="TransformationPivotTemplate">
        <telerikPrimitives:RadDataBoundListBox x:Name="TransformationList" CacheMode="BitmapCache" ItemsSource="{Binding Transformations, Mode=OneWay}" ItemTemplate="{StaticResource TransformationItemTemplate}" ItemContainerStyle="{StaticResource RadDataBoundListBoxItemStyle}" SelectionChanged="TransformationList_SelectionChanged"/>
    </DataTemplate>

    The TransformationItemTemplate follow below:
    <DataTemplate x:Key="TransformationItemTemplate">
        <Grid x:Name="LayoutRoot" CacheMode="BitmapCache" Background="{TemplateBinding Background}" HorizontalAlignment="Left" Margin="12,0,0,24" VerticalAlignment="Top">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="CommonStates">
                    <VisualState x:Name="Normal"/>
                    <VisualState x:Name="MouseOver"/>
                    <VisualState x:Name="Disabled"/>
                </VisualStateGroup>
                <VisualStateGroup x:Name="SelectionStates">
                    <VisualState x:Name="Unselected"/>
                    <VisualState x:Name="Selected"/>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Border Grid.RowSpan="2" BorderBrush="{StaticResource PhoneForegroundBrush}" BorderThickness="0" VerticalAlignment="Top" Margin="0">
                <Image Width="78" Height="60" Source="{Binding Icon}" Stretch="None" />
            </Border>
            <StackPanel Margin="18,0,0,0" VerticalAlignment="Top" d:LayoutOverrides="Width" Grid.Column="1">
                <TextBlock TextWrapping="Wrap" Text="{Binding Title}" Margin="0,-7,0,0"/>
                <TextBlock TextWrapping="Wrap" Text="{Binding Description}" FontSize="{StaticResource PhoneFontSizeSmall}">
                    <TextBlock.Foreground>
                        <SolidColorBrush Color="{StaticResource PhoneSubtleColor}"/>
                    </TextBlock.Foreground>
                </TextBlock>
            </StackPanel>
        </Grid>
    </DataTemplate>

    And the RadDataBoundListBoxItemStyle follow below:
    <Style x:Key="RadDataBoundListBoxItemStyle" TargetType="telerikPrimitives:RadDataBoundListBoxItem">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="HorizontalAlignment" Value="Stretch"/>
        <Setter Property="VerticalAlignment" Value="Stretch"/>
        <Setter Property="CacheMode" Value="BitmapCache"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="telerikPrimitives:RadDataBoundListBoxItem">
                    <Border x:Name="LayoutRoot" Background="{TemplateBinding Background}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver" />
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="Background">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TransparentBrush}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimation Storyboard.TargetName="ContentContainer" Storyboard.TargetProperty="Opacity" Duration="0" To=".5" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualState x:Name="Unselected"/>
                                <VisualState x:Name="Selected"/>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <ContentControl x:Name="ContentContainer"
                                          HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalAlignment}"
                                          HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                          Margin="{TemplateBinding Padding}"
                                          Content="{TemplateBinding Content}"
                                          ContentTemplate="{TemplateBinding ContentTemplate}"
                                          />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    Do you know what is happening?

    Best regards,

    Pieter Voloshyn
    Thumba Corporation
  2. Georgi
    Admin
    Georgi avatar
    296 posts

    Posted 31 Aug 2011 Link to this post

    Hi Pieter,

    Thank you for contacting us.

    The following statement in TransformationItemTemplate generates the problem:

    <DataTemplate x:Key="TransformationItemTemplate">
        <Grid x:Name="LayoutRoot" CacheMode="BitmapCache" Background="{TemplateBinding Background}">
    -----
        </Grid>
    </DataTemplate>

    Please note that TemplateBinding is valid only within the scope of a ControlTemplate XAML element. I suppose that prior to Mango this exception was not raised and that is why you see it now, when trying to upgrade to WP7.1. Of course the exception message could be more meaningful :) telling you where exactly the problem is. Visual states are also not valid within the scope of a DataTemplate, so you may remove them to prevent possible exception with future versions.

    I hope that this will help you solve the issue. If you continue to experience problems I would kindly ask you to prepare a sample project and attach it to a new support ticket so that I can debug the application and see what goes wrong.

    Best wishes,
    Georgi
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. DevCraft banner
Back to Top