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
1650
*Setting* the active record through binding
posted

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 

 


Parents Reply
  • 190
    posted in reply to Joe Modica

     Philipp Sumi is right. XamDataGrid looks very "WinFormisch". I would prefer "WPFisch" style, like a standard WPF Selector/MultiSelector control.

    Microsoft is now working on it's own DataGrid and it looks very "WPFisch". It is possible to use databinding with 0 (Zero) code. XamDataGrid can't be used without code behind. I had to write many code, only to set some property in my model.

    Solution with MultiValueConverter - you don't really mean that, didn't you? Why is it not part of XamDataGrid?

    Why XamDataGrid does not have a simple ActiveRecord from type Object. Why XamDataGrid does not makes the conversion itself? It knows better than I what is Record and how it can be converted back to my data objects.

    <XamDataGrid ItemsSource={Binding SomeData} SelectedItem={Binding SelectedData} />

    That's it. No converters, no code. Just so simple can it be.

Children