|
Query 1 : System.InvalidOperationException: ColumnName cannot be NULL |
We have noticed in your code snippet, you didn’t provide MappingName for GridTemplateColumn (which is bounded with MarkerColor). MappingName is necessary for all column. |
|
Query 2 : how deserialize at the openning moment of the sfDataGrid |
We already have an Serialization and Deserialization sample in our dashboard. For you reference we have attached the sample in below mentioned location.
Sample location: http://www.syncfusion.com/downloads/support/directtrac/general/ze/SerializationDemo1824354123
You can get the sample from dashboard from below path location.
\{installed location} \Syncfusion\EssentialStudio\{installedVersion}\WPF \ SfGrid.WPF\Samples\ SerializationDemo\.
You can refer the below UG links for more details.
|
|
<syncfusion:GridImageColumn MappingName="ImageLink" ImageHeight="50" ImageWidth="50"
HeaderText="Profile Pic"
ValueBinding="{Binding Path=ImageLink, Converter={StaticResource stringToImageConverter}}" />
private void Deserialize(object sender, RoutedEventArgs e)
{
if (dataGrid == null) return;
var options = new DeserializationOptions();
try
{
using (var file = File.Open("DataGrid.xml", FileMode.Open))
{
dataGrid.Deserialize(file, options);
foreach(var col in dataGrid.Columns)
{
if(col.MappingName == "ImageLink")
{
var index = dataGrid.Columns.IndexOf(col);
dataGrid.Columns.Remove(col);
var converter = new StringToImageConverter();
dataGrid.Columns.Insert(index,new GridImageColumn() {
MappingName = col.MappingName,
ValueBinding = new Binding("ImageLink") { Converter = converter }
});
}
}
}
}
catch (Exception)
{
}
} |