Home Forums WPF controls Xceed DataGrid for WPF Image Template Bug

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • Xceed Support
    Member
    Post count: 5658
    #23527 |

    Hi, I’m using this Image template:

    /// <summary>
    /// Create the image template
    /// </summary>
    /// <param name=”aColumn”>The column of the image </param>
    /// <param name=”aPropertyToBind”>The property to witch the source will be binded</param>
    /// <returns></returns>
    private ColumnEx CreateImageTemplate( ColumnEx aColumn, string aPropertyToBind )
    {
    FrameworkElementFactory imageEx = new FrameworkElementFactory( typeof( ImageEx ) );

    imageEx.SetValue( Image.SourceProperty, new Binding( aPropertyToBind ) );
    imageEx.SetValue( Image.NameProperty, “imageExTemplate” );
    imageEx.SetValue( Image.StretchProperty, Stretch.None );

    //CellEditorBinding
    CellEditorBindingExtension cellEditorBinding = new CellEditorBindingExtension();
    imageEx.SetBinding( Image.SourceProperty, cellEditorBinding.ProvideValue( null ) as BindingBase );

    DataTemplate dataTemplate = new DataTemplate();
    dataTemplate.VisualTree = imageEx;

    aColumn.CellEditor = null;
    aColumn.ReadOnly = true;
    aColumn.CellContentTemplate = dataTemplate;

    return aColumn;
    }

    And when I move an column header in a grid that uses this Image template, I have the following error:
    Is my template wrong or this is a bug in version 1.1?

    System.ArgumentOutOfRangeException = Specified argument was out of the range of valid values.
    Parameter name: index
    Message = Specified argument was out of the range of valid values.
    Parameter name: index
    Exception’s Data
    Message = Specified argument was out of the range of valid values.
    Parameter name: index
    ParamName = index
    (Dictionary with 1 entrie(s))
    TargetSite = T get_Item(Int32)
    Source = WindowsBase
    Stack Trace = at MS.Utility.FrugalObjectList`1.get_Item(Int32 index)
    at System.Windows.Freezable.GetChangeHandlersAndInvalidateSubProperties(EventStorage& calledHandlers)
    at System.Windows.Freezable.FireChanged()
    at System.Windows.Freezable.WritePostscript()
    at System.Windows.Media.Imaging.BitmapSource.remove_DownloadCompleted(EventHandler value)
    at System.Windows.Controls.Image.OnSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
    at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
    at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
    at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
    at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp)
    at System.Windows.StyleHelper.InvalidatePropertiesOnTemplateNode(DependencyObject container, FrameworkObject child, Int32 childIndex, FrugalStructList`1& childRecordFromChildIndex, Boolean isDetach, FrameworkElementFactory templateRoot)
    at System.Windows.StyleHelper.ClearTemplateChain(HybridDictionary[] instanceData, FrameworkElement feContainer, FrameworkContentElement fceContainer, List`1 templateChain, FrameworkTemplate oldFrameworkTemplate)
    at System.Windows.StyleHelper.ClearGeneratedSubTree(HybridDictionary[] instanceData, FrameworkElement feContainer, FrameworkContentElement fceContainer, FrameworkTemplate oldFrameworkTemplate)
    at System.Windows.StyleHelper.DoTemplateInvalidations(FrameworkElement feContainer, FrameworkTemplate oldFrameworkTemplate)
    at System.Windows.Controls.ContentPresenter.OnTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
    at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
    at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
    at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
    at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal)
    at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
    at System.Windows.Controls.ContentPresenter.OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
    at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
    at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
    at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
    at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp)
    at System.Windows.Data.BindingExpression.Invalidate(Boolean isASubPropertyChange)
    at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
    at System.Windows.Data.BindingExpression.ScheduleTransfer(Boolean isASubPropertyChange)
    at MS.Internal.Data.ClrBindingWorker.NewValueAvailable(Boolean dependencySourcesChanged, Boolean initialValue, Boolean isASubPropertyChange)
    at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)
    at MS.Internal.Data.PropertyPathWorker.OnDependencyPropertyChanged(DependencyObject d, DependencyProperty dp, Boolean isASubPropertyChange)
    at MS.Internal.Data.ClrBindingWorker.OnSourceInvalidation(DependencyObject d, DependencyProperty dp, Boolean isASubPropertyChange)
    at System.Windows.Data.BindingExpression.HandlePropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)
    at System.Windows.Data.BindingExpression.OnPropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)
    at System.Windows.DependentList.InvalidateDependents(DependencyObject source, DependencyPropertyChangedEventArgs sourceArgs)
    at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
    at System.Windows.DependencyObject.UpdateEffec

    Imported from legacy forums. Posted by Simon (had 2572 views)

    Xceed Support
    Member
    Post count: 5658

    You should not be using CellEditorBinding for a CellContentTemplate, only for a CellEditor.EditTempalte…

    Imported from legacy forums. Posted by Marcus [Xceed] (had 286 views)

    Xceed Support
    Member
    Post count: 5658

    /// <summary>
    /// Create the image template
    /// </summary>
    /// <param name=”aColumn”>The column of the image </param>
    /// <param name=”aPropertyToBind”>The property to witch the source will be binded</param>
    /// <returns></returns>
    private ColumnEx CreateImageTemplate( ColumnEx aColumn, string aPropertyToBind )
    {
    FrameworkElementFactory imageEx = new FrameworkElementFactory( typeof( ImageEx ) );

    imageEx.SetValue( Image.SourceProperty, new Binding( aPropertyToBind ) );
    imageEx.SetValue( Image.NameProperty, “imageExTemplate” );
    imageEx.SetValue( Image.StretchProperty, Stretch.None );

    //CellEditorBinding
    CellEditorBindingExtension cellEditorBinding = new CellEditorBindingExtension();
    //imageEx.SetBinding( Image.SourceProperty, cellEditorBinding.ProvideValue( null ) as BindingBase );
    imageEx.SetBinding( Image.SourceProperty, new Binding() );

    DataTemplate dataTemplate = new DataTemplate();
    dataTemplate.VisualTree = imageEx;

    aColumn.CellEditor = null;
    aColumn.ReadOnly = true;
    aColumn.CellContentTemplate = dataTemplate;

    return aColumn;
    }

    Now I’m not using the CellEditorBinding and it still do the same error.
    Any idea?

    Thanks for your help.

    Imported from legacy forums. Posted by Simon (had 3631 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.