Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
605
XamGrid UnboundColumn update
posted

Hello.

 

I created a solution with XamGrid, xaml example:

<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.

Converter's code:

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

Parents
No Data
Reply
  • 40030
    Verified Answer
    Offline posted

    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

     

Children