Home Forums WPF controls Xceed DataGrid for WPF timestamp field error

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #21654 |

    Hi

    When using a result set from a sqlserver database that includes a timestamp field, the following error occurs, (without a timstamp field there is no error)

    “No imaging component suitable to complete this operation was found”,

    here is the stack trace, hope it is of some use…

    at MS.Internal.HRESULT.Check(Int32 hr)
    at System.Windows.Media.Imaging.BitmapDecoder.SetupDecoderFromUriOrStream(Uri uri, Stream stream, BitmapCacheOption cacheOption, Guid& clsId, Boolean& isOriginalWritable, Stream& uriStream, UnmanagedMemoryStream& unmanagedMemoryStream, SafeFileHandle& safeFilehandle)
    at System.Windows.Media.Imaging.BitmapDecoder.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, Boolean insertInDecoderCache)
    at System.Windows.Media.Imaging.BitmapDecoder.Create(Stream bitmapStream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption)
    at System.Windows.Media.Imaging.BitmapFrame.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption)
    at System.Windows.Media.Imaging.BitmapFrame.Create(Stream bitmapStream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption)
    at System.Windows.Media.ImageSourceConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
    at System.ComponentModel.TypeConverter.ConvertFrom(Object value)
    at Xceed.Wpf.DataGrid.Column.GenericContentTemplateSelector.SelectTemplate(Object item, DependencyObject container)
    at Xceed.Wpf.DataGrid.Cell.DefaultContentTemplateSelector.SelectTemplate(Object item, DependencyObject container)
    at System.Windows.Controls.ContentPresenter.ChooseTemplate()
    at System.Windows.Controls.ContentPresenter.EnsureTemplate()
    at System.Windows.Controls.ContentPresenter.OnPreApplyTemplate()
    at System.Windows.FrameworkElement.ApplyTemplate()
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
    at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
    at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.Controls.Border.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.Controls.Control.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.Controls.StackPanel.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.Controls.DockPanel.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.Controls.Border.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.Controls.Control.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at Xceed.Wpf.DataGrid.VirtualizingCardPanel.MeasureFunct(Size& availableSize)
    at Xceed.Wpf.DataGrid.VirtualizingCardPanel.MeasureOverride(Size availableSize)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
    at System.Windows.Controls.ItemsPresenter.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
    at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
    at System.Windows.Controls.ScrollContentPresenter.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
    at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
    at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
    at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
    at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.Controls.Border.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.Controls.Control.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
    at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
    at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at MS.Internal.Helper.MeasureElementWithSin

    Imported from legacy forums. Posted by Alan (had 6000 views)

    Xceed Support
    Member
    Post count: 5658

    This all comes down to the fact that the representation of the “timestamp” data type is an array of bytes.

    We have included code in the data grid control that provides a <i>default</i> DataTemplate to display a column’s data when none is specified (through the Column.CellContentTemplate or Column.CellContentTemplateSelector properties).

    By default, when an array of byte is encountered ( and no template is provided), we interpret the byte[] as the data for an image.

    I have just submitted and enhancement request to correct this behavior and display a “neutral” template when data cannot be converted into an image.

    In the mean time, you can set a custom made DataTemplate on the timestamp Column’s CellContentTemplate. This will prevent the mechanism of “automatic” detection.

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

    User (Old forums)
    Member
    Post count: 23064

    thanks…

    Imported from legacy forums. Posted by Alan (had 471 views)

    User (Old forums)
    Member
    Post count: 23064

    This has been fixed in the latest release (Package v3.0.7113.09060, DatGrid assemblies v1.0.7113.3050), which has just been posted here:

    http://download3.xceedsoft.com/Packages/3.0.7113.09060/XceedComponents.exe

    The website has not yet been updated (release notes, update center, etc), but it will be soon.

    Imported from legacy forums. Posted by Pascal (had 387 views)

    User (Old forums)
    Member
    Post count: 23064

    If the data type is an System.Drawing.Image it does not work (the image is not displaye, instead, i see the ToString() implementation which is “system.drawing.bitmap”).

    What should I do if i want a cell to display an image which is part of the bounded data, when the data type is System.Drawing.Image?

    Imported from legacy forums. Posted by Guy (had 414 views)

    Xceed Support
    Member
    Post count: 5658

    Converting from a WinForms image class to a WPF image class is not a default, supported conversion…

    In order to display this, you would need to provide your own CellContentTemplate and use a converter you would have developed yourself…

    In the example below, I create such a template and use a small converter, developed in 5 minutes for the purpose of this post…

    Note that this is probably not one of most efficient way to program the converter, you will need to see is it addresses your needs.

    (see code in next post)

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

    Xceed Support
    Member
    Post count: 5658

    <code>
    <xcdg:Column FieldName=”myImage”>
    <xcdg:Column.CellContentTemplate>
    <DataTemplate>
    <Image>
    <Binding Path=”.”>
    <Binding.Converter>
    <local:WinFormsToWPFImageConverter/>
    </Binding.Converter>
    </Binding>
    </Image>
    </DataTemplate>
    </xcdg:Column.CellContentTemplate>
    </xcdg:Column>
    </code>

    The sample code for the converter is:

    <code>
    public class WinFormsToWPFImageConverter : IValueConverter
    {
    public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
    {
    if( value == null )
    {
    return null;
    }

    System.Drawing.Image myImage = value as System.Drawing.Image;

    if( myImage == null )
    {
    throw new NotSupportedException(“Convert can only convert from a System.Drawing.Image object to a System.Windows.Media.ImageSource”);
    }

    object retval = null;

    byte[] myOriginalArray = (byte[])new System.Drawing.ImageConverter().ConvertTo( value, typeof( byte[] ) );

    if( myOriginalArray != null )
    {
    retval = new ImageSourceConverter().ConvertFrom( myOriginalArray );
    }

    return retval;
    }

    public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
    {
    throw new NotSupportedException(“ConvertBack not supported on this converter”);
    }
    }
    </code>

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

    Xceed Support
    Member
    Post count: 5658

    Otherwise, you could always host on a WinForms control in the CellContentTemplate to display your System.Drawing.Bitmap.

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

    User (Old forums)
    Member
    Post count: 23064

    Greate reply! thanks! I will try it very soon.

    Imported from legacy forums. Posted by Guy (had 6556 views)

    User (Old forums)
    Member
    Post count: 23064

    <code>
    <xcdg:Column FieldName=”myImage”>
    <xcdg:Column.CellContentTemplate>
    <DataTemplate>
    <Image>
    <Binding Path=”.”>
    <Binding.Converter>
    <local:WinFormsToWPFImageConverter/>
    </Binding.Converter>
    </Binding>
    </Image>
    </DataTemplate>
    </xcdg:Column.CellContentTemplate>
    </xcdg:Column>
    </code>

     

    Above code gives error like – The type Image does not support direct content.

    What should be the correct one.

    Imported from legacy forums. Posted by Manoj (had 1204 views)

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