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
1405
DataBinding with XamNumericEditor not working
posted

Hy all.

I have a sample where I use databinding between a XamDataGrid and XamNumericEditor, but I think I miss something because it's not working.

In the xaml file I have a simple XamDataGrid with some fields and I fill the grid in the code behind:

<my:XamDataGrid Name="xamDataGrid1" GroupByAreaLocation="None" Theme="Office2k7Blue" Style="{StaticResource GridWithButtons}">

<my:XamDataGrid.FieldLayouts>

<my:FieldLayout>

<my:FieldLayout.Fields>

<my:Field Name="Title" Label="{Binding Path=headerTitle, Source={StaticResource resStaticData}, Mode=OneWay}" />

<my:Field Name="Running" Label="{Binding Path=headerRunning, Source={StaticResource resStaticData}, Mode=OneWay}"/>

<my:Field Name="MPAA" Label="{Binding Path=headerMPAA, Source={StaticResource resStaticData}, Mode=OneWay}"/>

<my:Field Name="Critics" Label="{Binding Path=headerCritics, Source={StaticResource resStaticData}, Mode=OneWay}"/>

<my:Field Name="Valid" Label="{Binding Path=headerValid, Source={StaticResource resStaticData}, Mode=OneWay}"/>

<my:Field Name="Load" Label="Load"/>

<my:Field Name="Date" Label="Date"

DataType="{x:Type sys:DateTime}"

Converter="{x:Static local:DateTimeConverter.Instance}">

<my:Field.Settings>

<my:FieldSettings EditAsType="{x:Type sys:String}"/>

</my:Field.Settings>

</my:Field>

</my:FieldLayout.Fields>

</my:FieldLayout>

</my:XamDataGrid.FieldLayouts>

</my:XamDataGrid>

private void Window_Loaded(object sender, RoutedEventArgs e)

{

DataTable t = GenerateData().Tables[0];

xamDataGrid1.DataSource = t.DefaultView;

}

public DataSet GenerateData()

{

DataSet ds = new DataSet();

DataTable dt = ds.Tables.Add("TopMovies");

dt.Columns.Add("Selected", typeof(bool));

dt.Columns.Add("Title", typeof(string));

dt.Columns.Add("Running", typeof(string));

dt.Columns.Add("MPAA", typeof(string));

dt.Columns.Add("Critics", typeof(string));

dt.Columns.Add("Valid", typeof(bool));

dt.Columns.Add("Load", typeof(float));

dt.Columns.Add("Date", typeof(DateTime));

dt.Rows.Add(new object[ { false, "Open Season", "1 hr. 40 min.", "PG", "C", true, 4.7, DateTime.Now });

dt.Rows.Add(new object[ { false, "Gridiron Gang", "120 min.", "PG-13", "C+", true, 7.2, DateTime.Now });

dt.Rows.Add(new object[ { false, "The Illusionist", "1 hr. 49 min.", "PG-13", "B", false, 78.3, DateTime.Now });

dt.Rows.Add(new object[ { false, "Pirates of the Caribbean: Dead Man's Chest", "145 min.", "PG-13", "B-", true, 78, DateTime.Now });

dt.Rows.Add(new object[ { false, "Open Season", "1 hr. 40 min.", "PG", "C", true, 34, DateTime.Now });

dt.Rows.Add(new object[ { false, "Gridiron Gang", "120 min.", "PG-13", "C+", true, 676, DateTime.Now });

dt.Rows.Add(new object[ { true, "The Illusionist", "1 hr. 49 min.", "PG-13", "B", false, 46, DateTime.Now });

dt.Rows.Add(new object[ { false, "Pirates of the Caribbean: Dead Man's Chest", "145 min.", "PG-13", "B-", true, 345, DateTime.Now });

dt.Rows.Add(new object[ { false, "Open Season", "1 hr. 40 min.", "PG", "C", true, 23, DateTime.Now });

dt.Rows.Add(new object[ { false, "Gridiron Gang", "120 min.", "PG-13", "C+", true, 53, DateTime.Now });

dt.Rows.Add(new object[ { true, "The Illusionist", "1 hr. 49 min.", "PG-13", "B", false, 67, DateTime.Now });

return ds;

}

I have a XamNumericEditor and I bound the Value propetry to the Load property of the items of the grid. But when I change the value in the XamNumericEditor, the value from the grid is not changed. Here is the XamNumericEditor.

<igEditors:XamNumericEditor Value="{Binding Path=Load, Mode=TwoWay}"/>

Thanks very much for any idea.

Nico

Parents
No Data
Reply
  • 1405
    Verified Answer
    posted

    Hy again.

    I found the problem. For the XamNumericEditor I was using a format like this: double:{0}.{1} but the type of the field Load was float and it didn't see it.

    Thanks very much any way.

    Nico

     

Children
No Data