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

Unhandled exception thrown on binding to image collection

1 Answer 54 Views
CoverFlow
This is a migrated thread and some comments may be shown as answers.
Larry
Top achievements
Rank 1
Larry asked on 27 Jan 2011, 12:19 AM
<telerik:RadCoverFlow Width="700" Canvas.ZIndex="1200"  Grid.Row="1" Grid.ColumnSpan="2" OffsetY="60" OffsetX="0" Opacity="0" ItemsSource="{Binding}" x:Name="Cover" SelectionChanged="Cover_Change" DistanceBetweenItems="50" ReflectionOpacity="2" ReflectionHeight="0.25" RotationY="45" ItemScale=".75" VerticalAlignment="Stretch" HorizontalAlignment="Left" Margin="10,30,35,20">
               <telerik:RadCoverFlow.Resources>
                   <Style TargetType="telerik:RadCoverFlowItem">
                       <Setter Property="telerik:RadDragAndDropManager.AllowDrag" Value="True"></Setter>
                   </Style>
               </telerik:RadCoverFlow.Resources>
               <telerik:RadCoverFlow.ItemTemplate>
                   <DataTemplate x:Name="cfDataTemplate">
                  
                       <ContentPresenter Content="{Binding ObtainedImage}"   HorizontalAlignment="Stretch" VerticalAlignment="Stretch" telerik:RadCoverFlow.EnableLoadNotification="True"></ContentPresenter>
             
       
                   </DataTemplate>
               </telerik:RadCoverFlow.ItemTemplate>
           </telerik:RadCoverFlow>
Hi Iam binding to the above coverflow an observableCollection<slide> of this slide class:
public class Slide
    {
        public Slide()
        {
 
          
        public string ImageName { get; set; }
 
        public BitmapImage ObtainedBitmap { get; set; }
 
        public Image ObtainedImage { get; set; }
     
    }

The images are obtained as a stream using WCF services and then bitmap images and Image objects are created from them. Everytime I bind the collection to the coverflow datacontext I get the following unhandled exception:

ExceptionObject {System.ArgumentException: Value does not fall within the expected range.
 
   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)
   at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)
   at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
   at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
   at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
   at System.Windows.DependencyObject.RefreshExpression(DependencyProperty dp)
   at System.Windows.Data.BindingExpression.SendDataToTarget()
   at System.Windows.Data.BindingExpression.SourceAcquired()
   at System.Windows.Data.BindingExpression.System.Windows.IDataContextChangedListener.OnDataContextChanged(Object sender, DataContextChangedEventArgs e)
   at System.Windows.Data.BindingExpression.DataContextChanged(Object sender, DataContextChangedEventArgs e)
   at System.Windows.FrameworkElement.OnDataContextChanged(DataContextChangedEventArgs e)
   at System.Windows.FrameworkElement.OnTreeParentUpdated(DependencyObject newParent, Boolean bIsNewParentAlive)
   at System.Windows.DependencyObject.UpdateTreeParent(IManagedPeer oldParent, IManagedPeer newParent, Boolean bIsNewParentAlive, Boolean keepReferenceToParent)
   at MS.Internal.FrameworkCallbacks.ManagedPeerTreeUpdate(IntPtr oldParentElement, IntPtr parentElement, IntPtr childElement, Byte bIsParentAlive, Byte bKeepReferenceToParent, Byte bCanCreateParent)}    System.Exception {System.ArgumentException}

And one less image gets displayed in the coverflow. Basically if there are 10 images that are obtained using WCF services and put into the collection and then the collection is binded to the coverflow datacontext, it throws the above exception and 9 images gets displayed with blank space for one of the images.

1 Answer, 1 is accepted

Sort by
0
George
Telerik team
answered on 31 Jan 2011, 10:18 AM
Hello Larry,

 
I would suggest you to use an Image control instead of ContentPresenter in the ItemTemplate of the RadCoverFlow control. It is not a good practice to use UIElement in your ViewModel. Then you could bind the Image.Source property to the ObtainedBitmap.

I hope this suit your needs.

Regards,
George
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
CoverFlow
Asked by
Larry
Top achievements
Rank 1
Answers by
George
Telerik team
Share this question
or