Hi,
I figured out how to display blob images and images from a path folder in a cell (behind code).
Whenever I select a image cell, the image dissapears. How can i make sure that it won't be vanished?
Thanks
Hi,
I figured out how to display blob images and images from a path folder in a cell (behind code).
Whenever I select a image cell, the image dissapears. How can i make sure that it won't be vanished?
Thanks
...The images are loaded from a database.
The Griddata control is binded with a property of type DataTable (which is loaded from a database)
<syncfusion:GridDataVisibleColumn MappingName="Image" Width="70"> <syncfusion:GridDataVisibleColumn.ColumnStyle>
<syncfusion:GridDataColumnStyle CellType="ImageCell">
</syncfusion:GridDataColumnStyle>
</syncfusion:GridDataVisibleColumn.ColumnStyle>
</syncfusion:GridDataVisibleColumn>
|
Thank you for the response. I dont setup the columnStyle in xaml code and the images are stored in the database as BLOB. The only thing I have in xaml code is this:
<sf:GridDataControl Name="asp" EnableVisualStyleForEditors="True"
ActivateCurrentCellBehavior="DblClickOnCell"
AutoGenerateColumnsInfo="True"
AutoPopulateColumns="True"
Grid.Row="1"
Grid.Column="0
IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding MyData}"
NotifyPropertyChanges="True"
UpdateMode="PropertyChanged"
Loaded="gridControl_Loaded" />
I setup the columnStyle in code behind :
private void gridControl_Loaded(object sender, RoutedEventArgs e)
{
this.gridControl.VisibleColumns[1].ColumnStyle.CellType = "ImageCell"
for (int i = 0; i < this.gridControl.Model.RowCount - 1; i++)
{
if (!string.IsNullOrEmpty(this.gridControl.Model[i + 1, 2].CellValue.ToString()))
{
this.gridControl.Model[i + 1, 2].CellValue = GetBitmapImage(this.gridControl.Model[i + 1, 2].CellValue as byte[]);
}
}
}
public DataTable MyData
{
get
{
return Data.GetDataTable();
}
}
void griddatacontrol_Loaded(object sender, RoutedEventArgs e)
{
var gridColumn1 = new GridDataVisibleColumn();
gridColumn1.MappingName = "Image";
GridDataColumnStyle style = new GridDataColumnStyle();
style.CellType = "ImageCell";
gridColumn1.ColumnStyle = style;
this.griddatacontrol.VisibleColumns.Add(gridColumn1);
var gridColumn2 = new GridDataVisibleColumn();
gridColumn2.MappingName = "Name";
this.griddatacontrol.VisibleColumns.Add(gridColumn2);
var gridColumn3 = new GridDataVisibleColumn();
gridColumn3.MappingName = "Title";
this.griddatacontrol.VisibleColumns.Add(gridColumn3);
} |
void griddatacontrol_Loaded(object sender, RoutedEventArgs e)
{
if (this.griddatacontrol.VisibleColumns["Image"].MappingName == "Image")
{
var column = this.griddatacontrol.VisibleColumns["Image"];
DataTemplate dt = new DataTemplate();
FrameworkElementFactory frameworkElement = new FrameworkElementFactory(typeof(Image));
Binding bind = new Binding();
bind.Source = new Uri(@"..\..\Images\USA.jpg", UriKind.Relative);
frameworkElement.SetBinding(Image.SourceProperty, bind);
DataTemplate template = new DataTemplate() { VisualTree = frameworkElement };
column.CellItemTemplate = template;
}
} |