Hi there
I know I can easily bind *to* a grid's active item by setting a binding using the ActiveRecord.DataItem property. However, how can I do it the other way round? I don't see a converter as a solution: The converter does not have a context (the grid), and this context cannot be assigned through a binding property because that would lead to a circular reference (if I declare it first, the binding fails, if I declare it later, the grid does not see the converter):
<UserControl.Resources> <!-- this binding does not work - the grid has not been created yet --> <conv:ActiveGridRowConverter x:Key="rowConverter" Grid="{Binding ElementName=contactGrid, Mode=OneTime}" /></UserControl.Resources><igDP:XamDataGrid x:Name="contactGrid" DataSource="{Binding Path=ContactStore.Contacts}" ActiveRecord="{Binding Path=ActiveContact.Contact, Converter={StaticResource rowConverter}}" />
I'm not sure whether I'm just overlooking the obvious - what's the recommended solution here?
Thanks,
Philipp
Hi,
Thanks for your answer, but it doesn't solve my problem... Here is my xaml implementation :
<igDP:XamDataGrid x:Name="XamDataGrid1" Theme="Office2k7Black" DataSource="{Binding Path=Sieges, Mode=TwoWay}" ActiveDataItem="{Binding Path=ObjetCourant, Mode=TwoWay, Converter={StaticResource activeDataItemConverter
}}">
And the converter :
public class ActiveDataItemConverter : IValueConverter
{
#region
IValueConverter Members
public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) {
return value;
}
public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) {
#endregion
The Convert method is never hit when I mark it with a breakpoint and modify the binded property... Are you sure that the TwoWay mode is supported ?
Sébastien
Hi Sébastien,
I'm not sure this is related to the ActiveDataItem property.
What you are seeing might be the result of a quirk in how 2-way bindings work. When a property value changes and gets pushed from the source to the target (or vice versa) if the receiving object synchronously changes the value to something else, the updated value doesn't get pushed back.
Could this be what is happening?
If so you can take adavntage of another quirk in 2-way bindings to get around the issue. It seems that if there is a Converter specified on the binding then the value does get pushed back. So try implementing an IValueConverter that just returns the passed in value for both methods and see if that solves the issue.
It seems that the ActiveDataItem property does'nt work with a TwoWay binding : I mean that it is possible to get the underlying DataItem when the selection changes but not to modify the selection when the binded property is modified.
Is there any guidance ?
Thanks in advance,
I found the property. Thanks
Shahin
Hi Shahin -
You can find the new ActiveDataItem property exposed directly on the XamDataGrid control just like the related ActiveRecord and Active Cell properties.
Please let me know if you have continued difficulty finding the property.
Joe