Skip to main content

Microsoft Silverlight

Answered Question SL3, RIA, and vanliia Textbox Binding?RSS Feed

(0)

pattormey
pattormey

Member

Member

35 points

18 Posts

SL3, RIA, and vanliia Textbox Binding?

New to SL...

 I'm trying to use RIA DomainDataSource without using the RIA DataFrorm. I want explicit control of the UI

But when I Bind to a vanilla SL3 TextBox

<StackPanel DataContext="{Binding Data, ElementName=ddsCities}"

<TextBox x:Name="txtName"
Text="{Binding Name, Mode=OneWay}"
 />

</StackPanel>

 I get (Below) in the Immediate Windows But it still works!

System.Windows.Data Error: BindingExpression path error: 'Name' property not found on 'System.Windows.Data.EntityCollectionView' 'System.Windows.Data.EntityCollectionView' (HashCode=48630964). BindingExpression: Path='Name' DataItem='System.Windows.Data.EntityCollectionView' (HashCode=48630964); target element is 'System.Windows.Controls.TextBox' (Name='txtName'); target property is 'Text' (type 'System.String')..

Any Idea of where I should look to Understand this

Thanks

Pat Tormey PE
MS MVP
New Hampshire USA
PTormey@4square.net

Fredrik N
Fredrik N

Participant

Participant

1126 points

228 Posts

Re: SL3, RIA, and vanliia Textbox Binding?

What kind of object will your ddsCities return (the method you specify as QueryName)? If it will return a single object with a property "Name", you shouldn't get any error. In your case it looks like it returns an EntityCollectionView.

/Fredrik Normén - fredrikn @ twitter

ASPInsider

Microsoft MVP, MCSD, MCAD, MCT

ASPInsiders
My Blog

pattormey
pattormey

Member

Member

35 points

18 Posts

Re: SL3, RIA, and vanliia Textbox Binding?

Hi Fredrik, 
  thanks!

It's returning a POCO List..

 Just full of play time data

 It does work.. It's the messages in the Immediate Window that confuse me..

Any help would be appreciated

 I'm followling the demo in the July 09 RIA Services DPF download.microsoft.com

[EnableClientAccess()]

public class CityService : DomainService
{
private CityData _cityData = new CityData();
public IEnumerable<City> GetCities()
{ return _cityData.Cities;}
}

public class CityData
{
private List<City> _cities = new List<City>();
public IList<City> Cities
{
get
{
LoadCities(); //loads the junk data
return this._cities;
}
}}

 

 

Pat Tormey PE
MS MVP
New Hampshire USA
PTormey@4square.net

Fredrik N
Fredrik N

Participant

Participant

1126 points

228 Posts

Answered Question

Re: SL3, RIA, and vanliia Textbox Binding?

I tried your example and I didn't get the error in the im. window. Here is my example code:

 

    <riaControls:DomainDataSource x:Name="ddsCities" QueryName="GetCities">
        <riaControls:DomainDataSource.DomainContext>
            <dc:MyDomainContext/>
        </riaControls:DomainDataSource.DomainContext>
    </riaControls:DomainDataSource>

    <StackPanel DataContext="{Binding Data, ElementName=ddsCities}">
        <TextBox Text="{Binding Name}"/>
    </StackPanel>


[EnableClientAccess()]
    public class MyDomainService : DomainService
    {
        public IEnumerable<City> GetCities()
        {
            return new List<City>()
                        {
                            new City() { ID = 0, Name = "New York" },
                            new City() { ID = 1, Name = "Stockholm" }
                        };
        }
    }

    public class City
    {
        [Key]
        public int ID { get; set; }

        public string Name { get; set; }
    }

/Fredrik Normén - fredrikn @ twitter

ASPInsider

Microsoft MVP, MCSD, MCAD, MCT

ASPInsiders
My Blog

pattormey
pattormey

Member

Member

35 points

18 Posts

Re: SL3, RIA, and vanliia Textbox Binding?

Thanks! Fredrik

I'll work from your example forward.

 

Pat Tormey PE
MS MVP
New Hampshire USA
PTormey@4square.net
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities