Question

Hello guys i have dataform in silverlight 4 project item source is:

ItemsSource="{Binding Data, ElementName=domainDataSource1, Mode=TwoWay}"

and domain data source is :

<riaControls:DomainDataSource Name="domainDataSource1" QueryName="GetCarsQuery"  AutoLoad="True">
        <riaControls:DomainDataSource.DomainContext>
            <domain:DataDomainContext/>
        </riaControls:DomainDataSource.DomainContext>
    </riaControls:DomainDataSource>

My cars table have relationship with trailers table. I have combobox on my data form where i want to show all trailers marks how i can bind combobox another query? And when user will save data how i can get trailers id with mark?

thanks

Was it helpful?

Solution

First let me preface this by saying ComboBoxes nested in DataForms are currently VERY buggy as of SL5. But here you go, this is using Entity Framework:

The associated class:

public class TrailerListProvider : UserControl
{
    myDomainContext _dc;
    public myDomainContext DomainContext
    {
        set
        {
            _dc = value;
            _dc.Load<trailer>(_dc.GetTrailersQuery());

        }
    }
    public TrailerListProvider()
    {
        DomainContext = new myDomainContext ();
    }
    public List<trailer> VendorList
    {
        get
        {
            return (from t in _dc.trailers
                    orderby t.trailerMark
                    select t).ToList();
        }
    }
}

In your XAML:

<Control.Resources>
    <myClasses:TrailerListProvider x:Key="trailerListProvider"></myClasses:TrailerListProvider>
</Control.Resources>

And finally in your combobox (or whatever control with ItemsSource):

ItemsSource = {Binding Path=VendorList, ElementName={StaticResource trailerListProvider}}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top