Cross DomainDataSource Combobox SelectedItem Binding

I'm new to data binding and XAML, so this is probably a pretty simple thing, but I was stumped on it for a few days (and disappointed with more googling than I can track at this point), and would appreciate any pointers in the right direction. My only preference is to keep it in pure XAML, if possible.

In my RIA SL4 project, I have two Entities PackageOSand OS, where it PackageOShas a connection with OSthrough PackageOS.OS(linking through PackageOS.OSIDโ†” OS.ID- and [Include]+ .Include()correctly configure the corresponding sections)

This is the template (defined in the section Page.Resourcealong with all other involved DDS) that I use in the DataForm to get an Entity OSEntitiesBinding List PackageOS(coming from the RIA GetOSEntities()using DDS)

<DataTemplate x:Key="POSItemTemplate">
    <StackPanel>
        <toolkit:DataField Label="PackageOS.OS">
            <TextBlock Text="{Binding Source={StaticResource packageOSEntityDomainDataSource}, Path=Data.CurrentItem.OS}" />
        </toolkit:DataField>
        <toolkit:DataField Label="OS">
            <ComboBox ItemsSource="{Binding Path=Data, Source={StaticResource osEntityDomainDataSource}}"
                      SelectedItem="{Binding Path=Data.CurrentItem.OS, Source={StaticResource packageOSEntityDomainDataSource}}"/>
        </toolkit:DataField>
    </StackPanel>
</DataTemplate>

The main problem is SelectedItem ComboBoxnot working. All bindings are accessible from the IDE binding wizard, so this is not a problem with entering the wrong path. I see that it packageOSEntityDomainDataSource.Data.CurrentItemhas a type PackageOS.

If I create a manual record in the backend database, the result is displayed in a text block PackageOS.OS, so I know that it returns correctly, but SelectedItemrefuses to select it (it finishes selecting the first value in the drop-down list, regardless of item OSc PackageOS).

Thank you very much in advance!

+3
1

. , - , , .

, Equality , , . IEquatable ( .shared.cs ), .

. Silverlight ComboBox Control Population by Manishdalal

DDS, . , DDS, / DDS, DomainContext , . , DDS , , , - ComboBox.

:

<DataTemplate x:Key="POSItemTemplate">
    <StackPanel d:DataContext="{Binding Source=packageOSDomainDataSource, Path=Data.CurrentItem}">
        <toolkit:DataField Label="OS">
            <ComboBox DisplayMemberPath="Name"
                      ItemsSource="{Binding Path=OSList, Source={StaticResource OSListGenerator}}"
                      SelectedItem="{Binding Path=OS, Mode=TwoWay}" />
        </toolkit:DataField>
    </StackPanel>
</DataTemplate>

OSListGenerator IEnumerable<OSEntity> OSList DomainContext

DDS DataTemplate TwoWay. ; , , , , SL3, , DDS DataTemplate SL4.

+1

Source: https://habr.com/ru/post/1792569/


All Articles