I want to use the GridView mode of a ListView to display a set of data that my program will be receiving from an external source. The data will consist of two arrays, one of column names and one of strings values to populate the control.
I don't see how to create a suitable class that I can use as the Item in a ListView. The only way I know to populate the Items is to set it to a class with properties that represent the columns, but I have no knowledge of the columns before run-time.
I could create an ItemTemplate dynamically as described in: Create WPF ItemTemplate DYNAMICALLY at runtime but it still leaves me at a loss as to how to describe the actual data.
Any help gratefully received.
You can add GridViewColumns to the GridView dynamically given the first array using a method like this:
private void AddColumns(GridView gv, string[] columnNames)
{
for (int i = 0; i < columnNames.Length; i++)
{
gv.Columns.Add(new GridViewColumn
{
Header = columnNames[i],
DisplayMemberBinding = new Binding(String.Format("[{0}]", i))
});
}
}
I assume the second array containing the values will be of ROWS * COLUMNS length. In that case, your items can be string arrays of length COLUMNS. You can use Array.Copy or LINQ to split up the array. The principle is demonstrated here:
<Grid>
<Grid.Resources>
<x:Array x:Key="data" Type="{x:Type sys:String[]}">
<x:Array Type="{x:Type sys:String}">
<sys:String>a</sys:String>
<sys:String>b</sys:String>
<sys:String>c</sys:String>
</x:Array>
<x:Array Type="{x:Type sys:String}">
<sys:String>do</sys:String>
<sys:String>re</sys:String>
<sys:String>mi</sys:String>
</x:Array>
</x:Array>
</Grid.Resources>
<ListView ItemsSource="{StaticResource data}">
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding Path=[0]}" Header="column1"/>
<GridViewColumn DisplayMemberBinding="{Binding Path=[1]}" Header="column2"/>
<GridViewColumn DisplayMemberBinding="{Binding Path=[2]}" Header="column3"/>
</GridView>
</ListView.View>
</ListView>
</Grid>
Thanks, that is very helpful.
I used it to create a dynamic version as follows. I created the column headings as you suggested:
private void AddColumns(List<String> myColumns)
{
GridView viewLayout = new GridView();
for (int i = 0; i < myColumns.Count; i++)
{
viewLayout.Columns.Add(new GridViewColumn
{
Header = myColumns[i],
DisplayMemberBinding = new Binding(String.Format("[{0}]", i))
});
}
myListview.View = viewLayout;
}
Set up the ListView very simply in XAML:
<ListView Name="myListview" DockPanel.Dock="Left"/>
Created an wrapper class for ObservableCollection to hold my data:
public class MyCollection : ObservableCollection<List<String>>
{
public MyCollection()
: base()
{
}
}
And bound my ListView to it:
results = new MyCollection();
Binding binding = new Binding();
binding.Source = results;
myListview.SetBinding(ListView.ItemsSourceProperty, binding);
Then to populate it, it was just a case of clearing out any old data and adding the new:
results.Clear();
List<String> details = new List<string>();
for (int ii=0; ii < externalDataCollection.Length; ii++)
{
details.Add(externalDataCollection[ii]);
}
results.Add(details);
There are probably neater ways of doing it, but this is very useful for my application. Thanks again.
This article on the CodeProject explains exactly how to create a Dynamic ListView - when data is known only at runtime.
http://www.codeproject.com/KB/WPF/WPF_DynamicListView.aspx
Not sure if it's still relevant but I found a way to style the individual cells with a celltemplate selector. It's a bit hacky because you have to munch around with the Content of the ContentPresenter to get the proper DataContext for the cell (so you can bind to the actual cell item in the cell template):
public class DataMatrixCellTemplateSelectorWrapper : DataTemplateSelector
{
private readonly DataTemplateSelector _ActualSelector;
private readonly string _ColumnName;
private Dictionary<string, object> _OriginalRow;
public DataMatrixCellTemplateSelectorWrapper(DataTemplateSelector actualSelector, string columnName)
{
_ActualSelector = actualSelector;
_ColumnName = columnName;
}
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
// The item is basically the Content of the ContentPresenter.
// In the DataMatrix binding case that is the dictionary containing the cell objects.
// In order to be able to select a template based on the actual cell object and also
// be able to bind to that object within the template we need to set the DataContext
// of the template to the actual cell object. However after the template is selected
// the ContentPresenter will set the DataContext of the template to the presenters
// content.
// So in order to achieve what we want, we remember the original DataContext and then
// change the ContentPresenter content to the actual cell object.
// Therefor we need to remember the orginal DataContext otherwise in subsequent calls
// we would get the first cell object.
// remember old data context
if (item is Dictionary<string, object>)
{
_OriginalRow = item as Dictionary<string, object>;
}
if (_OriginalRow == null)
return null;
// get the actual cell object
var obj = _OriginalRow[_ColumnName];
// select the template based on the cell object
var template = _ActualSelector.SelectTemplate(obj, container);
// find the presenter and change the content to the cell object so that it will become
// the data context of the template
var presenter = WpfUtils.GetFirstParentForChild<ContentPresenter>(container);
if (presenter != null)
{
presenter.Content = obj;
}
return template;
}
}
Note: I changed the DataMatrix frome the CodeProject article so that rows are Dictionaries (ColumnName -> Cell Object).
I can't guarantee that this solution will not break something or will not break in future .Net release. It relies on the fact that the ContentPresenter sets the DataContext after it selected the template to it's own Content. (Reflector helps a lot in these cases :))
When creating the GridColumns, I do something like that:
var column = new GridViewColumn
{
Header = col.Name,
HeaderTemplate = gridView.ColumnHeaderTemplate
};
if (listView.CellTemplateSelector != null)
{
column.CellTemplateSelector = new DataMatrixCellTemplateSelectorWrapper(listView.CellTemplateSelector, col.Name);
}
else
{
column.DisplayMemberBinding = new Binding(string.Format("[{0}]", col.Name));
}
gridView.Columns.Add(column);
Note: I have extended ListView so that it has a CellTemplateSelector property you can bind to in xaml
#Edit 15/03/2011:
I wrote a little article which has a little demo project attached: http://codesilence.wordpress.com/2011/03/15/listview-with-dynamic-columns/
Totally progmatic version:
var view = grid.View as GridView;
view.Columns.Clear();
int count=0;
foreach (var column in ViewModel.GridData.Columns)
{
//Create Column
var nc = new GridViewColumn();
nc.Header = column.Field;
nc.Width = column.Width;
//Create template
nc.CellTemplate = new DataTemplate();
var factory = new FrameworkElementFactory(typeof(System.Windows.Controls.Border));
var tbf = new FrameworkElementFactory(typeof(System.Windows.Controls.TextBlock));
factory.AppendChild(tbf);
factory.SetValue(System.Windows.Controls.Border.BorderThicknessProperty, new Thickness(0,0,1,1));
factory.SetValue(System.Windows.Controls.Border.MarginProperty, new Thickness(-7,0,-7,0));
factory.SetValue(System.Windows.Controls.Border.BorderBrushProperty, Brushes.LightGray);
tbf.SetValue(System.Windows.Controls.TextBlock.MarginProperty, new Thickness(6,2,6,2));
tbf.SetValue(System.Windows.Controls.TextBlock.HorizontalAlignmentProperty, column.Alignment);
//Bind field
tbf.SetBinding(System.Windows.Controls.TextBlock.TextProperty, new Binding(){Converter = new GridCellConverter(), ConverterParameter=column.BindingField});
nc.CellTemplate.VisualTree = factory;
view.Columns.Add(nc);
count++;
}
I would go about doing this by adding an AttachedProperty to the GridView where my MVVM application can specify the columns (and perhaps some additional metadata.) The Behavior code can then dynamically work directly with the GridView object to create the columns. In this way you adhere to MVVM and the ViewModel can specify the columns on the fly.
Related
From my ViewModel, I need to programmatically move the focus and highlight of a row in a WPF DataGrid. The DataGrid has just one column:
<DataGrid Name="DgAdrType"
ItemsSource="{Binding ItemsLcv}"
IsSynchronizedWithCurrentItem="True"
<DataGridTextColumn Header=" Description"
IsReadOnly="True"
CanUserSort="True" Binding="{Binding descr, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
And in the datacontext ViewModel:
private IEnumerable<AdrTypeMdl> _itemsList;
ItemsLcv = CollectionViewSource.GetDefaultView(_itemsList) as ListCollectionView;
This works even though I don't have a property per se in the ViewModel for the data field "descr", because I bind the DataGrid's ItemSource.
In the ViewModel I can access the View DataGrid's ItemCollection of items by passing in that ItemCollection from the View like so:
<!-- Interaction for click selection -->
<i:Interaction.Triggers>
<i:EventTrigger EventName="GotMouseCapture">
<i:InvokeCommandAction Command="{Binding SelObjChangedCommand}"
CommandParameter="{Binding ElementName=DgAdrType, Path=Items}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
And back in the ViewModel, I load the DataGrid items like so:
private ItemCollection _dgItems;
private void SelObjChanged(object theItems)
{if (theItems !=null)
{ _dgItems = theItems as ItemCollection;
I want to keep the cast to ItemCollection so that I can retain the DataGrid properties of that ItemCollection. The problem is the ItemCollection's IndexOf method is not working. I only get -1 when I try to find the index of one of the class object items by doing this.
var idx = _dgItems.IndexOf(myobject);
EDIT ------- this is entire code of the method try IndesOf
private void HandleUpdateListEvent(Object myobject)
{AdrTypeMdl theNewItem = myobject as AdrTypeMdl;
bool co = _dgItems.Contains(theNewItem);
var idx = _dgItems.IndexOf(theNewItem);
_dgItems.MoveCurrentToPosition(idx);
_dgItems.Refresh();}
EDIT ---------------------------------
This is the easier approach but I still need help with the lambda / filter expression and method call
// this is where I try to get the index of an object for highlighting
private void HandleUpdateListEvent(Object myobject)
AdrTypeMdl theNewItem = myobject as AdrTypeMdl;
var e = ItemsLcv.SourceCollection.GetEnumerator();
ItemsLcv.Filter = o => (o == theNewItem);
foreach (row in ItemsLcv)
{ if row == theNewItem
return e >;
e = -1;}
ItemsLcv.MoveCurrentToPosition(e);
ItemsLcv.Refresh();}
END EDIT ---------------------
In debugger I can see the class Objects in _dgItems. If I do this, it works.
var idx = _dgItems.IndexOf(_dgItems[2]);
But the IndexOf method does not work when the parameter is just a class Object. I think the problem is with my cast of the DataGrid items to an ItemCollection. I need to cast the class Object, ie. myobject, to something recognizable by the ItemCollection that I got from the DataGrid. Is there a workaround? Thank you.
Try this.
You need to cast it to the type of collection ie AdrTypeMdl. You cannot simply get the index by passing an object. You're binding to a source ItemsLcv which is of type AdrTypeMd1. So pass that exact type to get the exact index.
var dgcolumn = myobject as AdrTypeMdl;
if(dgcolumn != null)
{
var idx = _dgItems.IndexOf(dgcolumn);
}
idx will be the index of that corresponding column.
Need help on below errors highlighted in the code comments shown below
The purpose of the below method is to find an combox item byvalue and set it to combobox if present else add it to combobox and then set it.
private void SetComboBoxValueHelper(ComboBox cb, string valuetoSet)
{
bool isValueNotFound = false;
cb.SelectedValue = valuetoSet;
isValueNotFound = string.IsNullOrEmpty(Convert.ToString(cb.SelectedValue));
if (isValueNotFound)
{
//try to ignore case and find the item in combobox
foreach (ComboBoxItem item in cb.Items) //1.ERROR AFTER ANY ITEM ADDED using my code
{
if (string.Compare(Convert.ToString(item.Content), valuetoSet, true) == 0)
{
cb.SelectedValue = item.Content;
isValueNotFound = false;
}
}
//if still not found add the item to the combobox
if (isValueNotFound)
{
cb.Items.Add(valuetoSet);
cb.SelectedValue = valuetoSet;//2.THIS IS NOT WORKING
}
}
}
A sample combobox i use is
<ComboBox Grid.Column="5" Grid.Row="4" Margin="10" Name="cbbox1" SelectedValuePath="Content">
<ComboBoxItem Content="No" IsSelected="True" />
<ComboBoxItem Content="Yes" />
</ComboBox>
Please let me know
a)how i can fix that non working line.
b)I get error at line shown in comment. how do i prevent it.
The problem here is that you are adding a string to the ComboBox's Items:
cb.Items.Add(valuetoSet);
You should instead add a new ComboBoxItem:
cb.Items.Add(new ComboBoxItem { Content = valuetoSet });
Otherwise you mix ComboBoxItems and strings in the Items collection. Now when you iterate over the items as ComboBoxItems, you get an exception when the added string item is encountered.
You should however consider to use string items instead of ComboBoxItems. That would make your code cleaner and you could address the selected string item directly by the SelectedItem property, without any need for SelectedValuePath and stuff like Convert.ToString(item.Content).
You could even define the initial item strings in XAML like this:
<ComboBox xmlns:sys="clr-namespace:System;assembly=mscorlib"
SelectedIndex="0" ...>
<sys:String>No</sys:String>
<sys:String>Yes</sys:String>
</ComboBox>
Now your whole SetComboBoxValueHelper method would simplify as Novitchi has written:
private void SetComboBoxValueHelper(ComboBox cb, string valuetoSet)
{
if (!cb.Items.Contains(valuetoSet))
{
cb.Items.Add(valuetoSet);
}
cb.SelectedItem = valuetoSet;
}
EDIT: If there is still any need to iterate over the items, you would also iterate over strings instead of ComboBoxItems:
foreach (string item in cb.Items)
{
...
}
As Clemens already suggested you shouldn't mix the ComboBoxItems and String. From XAML you adding to combobox ComboBoxItems, from code you adding Strings. A simple solution will be to set all Items as string. For this you should add your Yes, No items from code too.
Then your SetComboBoxValueHelper should look like this:
private void SetComboBoxValueHelper(ComboBox cb, string valuetoSet)
{
bool valueNotFound = !cb.Items.Contains(valuetoSet);
if (valueNotFound)
cb.Items.Add(valuetoSet);
cb.SelectedItem = valuetoSet;
}
The wpf will create the ComboBoxItem for you and you can get it using
cb.ItemContainerGenerator.ContainerFromItem("ItemString");
I have a DataGrid (dataGrid1) where records can be added and deleted.
Based on that dataGrid1, I want to make a new Grid with buttons in it based on ID and Types'. Cols will also have to given a DataSource of add dynamically, but that will be just while generating for the 1st time in Window_Loaded itself. Rows can be added/removed based on changes in dataGrid1. I want somethign like this :
On each Btn click, a new window will be opened for entry of the particular Type and for the particular ID. If the details are already entered, then the text of btn wil be "Update" else "Add".
What could be the best resource/control to perform this operations ? At present, I just did a Grid with 2 stable cols. Any ideas for the above to use Grid, DataGrid or something else. And adding/removing rows will be easy in which way and how.
Any help is appreciated.
Okay, let me try to take an example which is similar to your needs
Let's assume we use this class:
public class MyObject
{
public int MyID;
public string MyString;
public ICommand MyCommand;
}
And we are willing to display a DataGrid listing the ID, and having as a second column a Button, with the property MyString as content, which, when clicked, launches the ICommand MyCommand which opens in a new window whatever you want.
Here is what you should have on the View side:
<DataGrid ItemsSource="{Binding MyList}" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="ID" Binding="{Binding MyID}" />
<DataGridTemplateColumn Header="Buttons">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="{Binding MyString}" Command="{Binding MyCommand}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
This will show a DataGrid taking all the content in an IEnumerable<MyObject> named 'MyList', and shows two columns as defined before.
Now if you need to define the command.
First, I recommend you read this introductory link to MVVM and take the RelayCommand class (that's what we're gonna use for your problem)
So, in your ViewModel, the one which defines the MyList, here is how you should define some of the useful objects:
public ObservableCollection<MyObject> MyList { get; set; }
// blah blah blah
public void InitializeMyList()
{
MyList = new ObservableCollection<MyObject>();
for (int i = 0; i < 5; i++)
{
MyList.Add(InitializeMyObject(i));
}
}
public MyObject InitializeMyObject(int i)
{
MyObject theObject = new MyObject();
theObject.MyID = i;
theObject.MyString = "The object " + i;
theObject.MyCommand = new RelayCommand(param =< this.ShowWindow(i));
return theObject
}
private void ShowWindow(int i)
{
// Just as an exammple, here I just show a MessageBox
MessageBox.Show("You clicked on object " + i + "!!!");
}
This should be enough to create whatever you want. As you can see, every Button will call a method (ShowWindow) which is defined to show your new window, do whatever you need inside. The RelayCommand is actually just here, as its name says, to relay the command fired by the button to a method which contains the execution logic.
And... I think that's all you need. Sorry for the late answer BTW
EDIT - generating columns manually/dynamically
The following code is part of a code I had to do when I had a similar problem.
My problem was, I needed to change the columns displayed every time a ComboBox's SelectedItem would change. So I put this in a SelectionChanged event handler.
I don't know where exactly do you need to generate your columns, but I'll give you a general example.
Assume your ItemsSource is an ObservableCollection<MyNewObject>
MyNewObject is the following:
public class MyNewObject
{
public IList<string> MyStrings { get; set; }
}
You should put somewhere in your code (should be when you need to generate the column) the following code, which is generating a number of columns equal to the length of the first MyNewObject from the list (note: this is in code-behind, and the DataGrid you're working on is named dataGrid)
ObservableCollection<MyNewObject> source = dataGrid.ItemsSource as ObservableCollection<MyNewObject>;
if (source == null || source.Count == 0)
{
return;
}
MyNewObject firstObject = source[0];
for(int i = 0; i < firstObject.MyStrings.Count; i++)
{
// Creates one column filled with buttons for each string
DataGridTemplateColumn columnToAdd = new DataGridTemplateColumn();
columnToAdd.Width = 110; // I set a manual width, but you can do whatever you want
columnToAdd.Header = "Header number " + i;
// Create the template with a Button inside, bound to the appropriate string
DataTemplate dataTemplate = new DataTemplate(typeof(Button));
FrameworkElementFactory buttonElement = new FrameworkElementFactory(typeof(Button));
Binding binding = new Binding("MyStrings[" + i + "]");
binding.Mode = BindingMode.TwoWay;
binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
buttonElement.SetBinding(Button.ContentProperty, binding);
// Do the same here for your command, or for whatever you want to do when the user clicks on this button
dataTemplate.VisualTree = buttonElement;
columnToAdd.CellTemplate = dataTemplate;
dataGrid.Columns.Add(columnToAdd);
}
This will create one column for each string found in the first object. Then, enhance it with whatever command or display trick you need!
I have
a collection of StackPanel which each one includes a dynamic set of controls (based on database values), I want to set them as ItemsSource of some ComboBox
for example i have two database values which should be generated:
In DB i have these:
row 1=>Class [a] p [B] , [AB]vb
row 2=>Class tpy rbs=[sdfg],kssc[h] hm
and each one should generate as a ComboBox column like the fallowing:
In ComboBox I wanna generate these :
ComboBoxItem 1 :Class [a textBox] p [a textBox] , [a textBox]vb
ComboBoxItem 2 :Class tpy rbs=[a textBox].kssc[a textBox] hm
the fallowing code is doing this right:
Class ConvertToControlsFormat()
{
Regex exp = new Regex(#"\[\w*\]");
var source = new TestEntities().cmbSources;
foreach (var item in source)
{
StackPanel p = new StackPanel { Orientation = Orientation.Horizontal, FlowDirection = FlowDirection.LeftToRight };
int i = 0;
foreach (string txt in exp.Split(item.Title))
{
p.Children.Add(new TextBlock { Text = txt });
if (i < exp.Matches(item.Title).Count)
p.Children.Add(new TextBox { Text = exp.Matches(item.Title)[i].Value, Width = 30 });
}
cmb.Items.Add(p);
}
}
But I cant set TwoWay DataBindings for that, so I created a list of StackPanel as a field of cmbSource class (which is bound to ItemsSource of the ComboBox)
public partial class cmbSource
{
#region Primitive Properties
int iD;
public virtual int ID
{
get
{
if (Title != null)
ControlsCollection = SetControlsCollection(Title);
return iD;
}
set
{
iD = value;
}
}
private StackPanel SetControlsCollection(string ttl)
{
Regex exp = new Regex(#"\[\w*\]");
StackPanel p = new StackPanel { Orientation = Orientation.Horizontal, FlowDirection = System.Windows.FlowDirection.LeftToRight };
int i = 0;
foreach (string txt in exp.Split(ttl))
{
p.Children.Add(new TextBlock { Text = txt });
if (i < exp.Matches(ttl).Count)
p.Children.Add(new TextBox { Text = exp.Matches(ttl)[i].Value, Width = 30 });
}
return p;
}
public virtual string Title
{
get;
set;
}
public virtual StackPanel ControlsCollection
{
get;
set;
}
#endregion
}
but I have no idea of how bind it to ItemsSource of my ComboBox
Summery:I want to bind a list of controls to a ComboBox
any suggestions!? thank you.
EDIT
First: you do not bind a ComboBox to a collection of UI Elements. That is not the way WPF works. Container controls such as the Grid, StackPanel and Canvas can contain child controls. ItemsControls such as the ComboBox contain data objects and use DataTemplates to display the items.
Secondly: if the database can contain ANY data that could cause ANY UI to be needed you will need to generate the UI in code by creating StackPanels etc. adding controls and bindings as you do in your code examples.
Thirdly: the reason you can't bind is that the data from the database is a string that you split into parts; there is no way you can simply go back to the string.
Suggestion: the string in the database is probably (I hope) in some sort of format. Using that knowledge you could generate a new format string when you are parsing the database string. E.g., when the database contains foo [bar] you could generate {0} [bar]. On a save action from the user you could use that string to create the updated string for the database by using: String.Format("{0} [bar]", someControl.Text)
Extra: Please, next time, use better names and example texts; the question is unreadable like this. There is no way you can expect us to understand 2=>Class tpy rbs=[sdfg],kssc[h] hm
OLD ANSWER
Make a class Stuff, implementing INotifyPropertyChanged and having the properties Name and Value.
Load the database data into an ObservableCollection<Stuff> and bind the ComboBox to this collection.
Set the ItemTemplate of the combo box to a datatemplate like this:
<ComboBox ItemsSource="{Binding}">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}"/>
<TextBox Text="{Binding Value}"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
I am trying to populate a WPF datagrid but it's only showing the column headers and the content cells of the first(!) column. All other cells are empty:
The DataGrid is defined like this:
<DataGrid ItemsSource="{Binding Classifications, Mode=OneWay}"
AutoGenerateColumns="True" HeadersVisibility="Column" />
Classifications is defined in the code-behind file like this:
public DataView Classifications
{
get
{
return ClassificationDataTable.GetTable(myData).DefaultView
}
}
and finally this is my data generator:
public static class ClassificationDataTable
{
public static DataTable GetTable(List<Classification> classifications)
{
DataTable table = new DataTable();
// build columns
table.Columns.Add("FruitPrototype", typeof (string));
foreach (var featureComparison in classifications[0].FeatureComparisons)
table.Columns.Add(featureComparison.FeatureName, typeof (double));
// add rows
foreach (var classification in classifications)
{
object[] values = new object[classification.FeatureComparisons.Count+1];
values[0] = classification.FruitPrototype.FruitType;
for (int i = 0; i < classification.FeatureComparisons.Count; i++)
values[i + 1] = classification.FeatureComparisons[i].NormalizedDistance;
table.Rows.Add(values);
}
return table;
}
}
I verified the binding and can confirm that the DefaultView of the DataTable is indeed bound to the ItemsSource of my DataGrid. Also, the double values that should be shown in the grid are != 0.
What am I missing here?
I figured it out with the help of Jimmy W's question: I had some brackets and dots in the column names which somehow broke the binding of the cells. Changing the values of the feature names in
table.Columns.Add(featureComparison.FeatureName, typeof (double));
fixed my problem.