Hello.
<Grids:XamGrid x:Name="grid" Height="100" AutoGenerateColumns="False"
ItemsSource="{Binding Collection,Mode=OneWay}" >
<Grids:XamGrid.Columns>
<Grids:TextColumn Key="Name" />
<Grids:UnboundColumn Key="UnbColumn"
ValueConverter="{StaticResource UnboundConverter}" >
</Grids:UnboundColumn>
</Grids:XamGrid.Columns>
</Grids:XamGrid>
I have a converter that must calculate output value by some fields of value object.
public class UnboundConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
var testClass = value as TestClass;
if(testClass != null)
return testClass.UnbColumn;
}
return null;
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
throw new NotImplementedException();
Collection is ObservableCollection<>.
TestClass is a simple class wich has 2 string fields.
Than, if I try change some element in collection like this:
Collection[0].Name = "newName";
Collection[0].UnbColumn = "newValue";
After that, value in column "Name" is change, but value in column "UnbColumn " still not change.
So, what I should do to change value on UnboundColumn?
Alexey Lukyanov
In my case I can't use bound fields.
I try grid.InvalidateData() and it works correctly
Thank you, Steve!
Hi Alexey,
So UnboundColumns have no fields to listen to, so they don't update when modifying the underlying data, which is why we recommend you use bound fields and have your view model have your calculated value. Then you can raise a PropertyChanged event when the underlying data changes.
Otherwise, if you have the cell, you can call Refresh() on it: something like: grid.Rows[0].Cells[0].Refresh()
And perhaps, you could try grid.InvalidateData()
-SteveZ