This question is locked. New answers and comments are not allowed.
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)
{
}
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)
{
}