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

browser exception

3 Answers 84 Views
CoverFlow
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Colin Cowie
Top achievements
Rank 1
Colin Cowie asked on 02 Mar 2011, 02:59 PM
I have a coverflow bound to an observable collection of Uri's, which works fine, except when the images cannot be loaded, because the Uri path is invalid.

When this happens I am getting a browser exception generated in Internet Explorer as follows:

Error: Unhandled Error in Silverlight Application
Code: 4009    
Category: ManagedRuntimeError       
Message: Element is already the child of another element.     

Handling the ImageFailed event of the Image control doesn't seem to stop this message as it does with our other display of images

My original code was using a collection of strings (which were in effect absolute Uri's), but I have now changed the code to convert this to a collection of Uri's, and I even tried copying the xaml from your binding example incase I had something wrong there, but it still gives this error.

The only real difference I can see is that mine is executing inside a RadWindow.  Could you let me know what I'm doing wrong and how to suppress this error message?

Thanks,

Colin.

Xaml below:

<telerikNavigation:RadWindow Style="{StaticResource RadWindowStyle}" Height="Auto" Width="Auto"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    xmlns:telerikPrimitives="clr-namespace:Telerik.Windows.Controls.Primitives;assembly=Telerik.Windows.Controls"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
    x:Class="TranSend.Core.PhotoDisplay"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:localcore="clr-namespace:TranSend.Core"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <telerikNavigation:RadWindow.Resources>
        <localcore:IntPlusParameterConverter x:Key="IntPlusParameterConverter" />
        <DataTemplate x:Key="PhotoTemplate">
            <Image Source="{Binding}" Width="640" Height="480" Stretch="Uniform" telerik:RadCoverFlow.EnableLoadNotification="True" ImageFailed="Image_ImageFailed" />
        </DataTemplate>

    </telerikNavigation:RadWindow.Resources>
    
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <telerik:RadCoverFlow Grid.Row="0" x:Name="PhotoFlow" Height="520" Width="1000" IsReflectionEnabled="False"
                              ItemTemplate="{StaticResource PhotoTemplate}" />
        <ScrollBar
                    Grid.Row="1" Orientation="Horizontal" SmallChange="1"
                    LargeChange="1" Minimum="0"
                    Value="{Binding ElementName=PhotoFlow, Path=SelectedIndex, Mode=TwoWay}"
                    Maximum="{Binding ElementName=PhotoFlow, Path=ItemsSource.Count, Converter={StaticResource IntPlusParameterConverter}, ConverterParameter=-1}" />

    </Grid>
</telerikNavigation:RadWindow>



code-behind:

        private ObservableCollection<string> _photos;
        public ObservableCollection<string> Photos
        {
            get { return _photos; }
            set { _photos = value; DisplayPhotos(); RaisePropertyChanged("Photos"); }
        }

        private ObservableCollection<Uri> _PhotoUris;

        public ObservableCollection<Uri> PhotoUris
        {
            get { return _PhotoUris; }
            set { _PhotoUris = value; }
        }

        public PhotoDisplay()
        {
            InitializeComponent();
            this.DataContext = PhotoUris;
        }

        public void DisplayPhotos()
        {
            PhotoUris = new ObservableCollection<Uri>();
            foreach (var _photo in Photos)
            {
                PhotoUris.Add(new Uri(_photo, UriKind.Absolute));
            }
            PhotoFlow.ItemsSource = PhotoUris;

        }
        private void Image_ImageFailed(object sender, ExceptionRoutedEventArgs e)
        {
        }

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 07 Mar 2011, 01:21 PM
Hi Colin Cowie,

This is a general error which indicates that an element has two parents.
We've tried to reproduce this issue using the provided code but to no avail. I've attached our test files for a reference.  Could you please download the attachment and try it?

If you still experience the issue, open a support ticket and send us a sample project there. Thanks

Regards,
Yana
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
JULIO
Top achievements
Rank 1
answered on 25 May 2011, 12:59 AM
Same error, cant find event HyperlinkButton_Click, but vs2010 marks it just like an event, no errors on building:

Mainpage.xaml.cs
private void HyperlinkButton_Click(object sender, RoutedEventArgs  e)
 { ... }
Mainpage.xaml

    <Grid x:Name="LayoutRoot">

    <telerikNavigation:RadCoverFlow ItemsSource="{StaticResource ControlInfoList }">

 

    <telerikNavigation:RadCoverFlow.ItemTemplate>

 

    <DataTemplate>

 

 

 

 

    <Border BorderBrush="{StaticResource BorderBrush}" >

 

 

    <StackPanel Style="{StaticResource PanelStyle }">

 

 

    <StackPanel Orientation ="Horizontal">

 

    <Image Source="{Binding Logo}" Style="{StaticResource ImageStyle }" />

 

    <TextBlock Text="{Binding Name}" Style="{StaticResource TitleStyle }" />

 

    </StackPanel >
     <HyperlinkButton Content="{Binding Texto}" NavigateUri="{Binding Liga}" click="HyperlinkButton_Click" />

 

 

 

 

 

 

 

 

 

 

 

 

0
Yana
Telerik team
answered on 25 May 2011, 03:48 PM
Hello Julio,

I've attached a simple page based on your code which works as expected at our side, please download it and examine it.

Kind regards,
Yana
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
Tags
CoverFlow
Asked by
Colin Cowie
Top achievements
Rank 1
Answers by
Yana
Telerik team
JULIO
Top achievements
Rank 1
Share this question
or