Silverlight binding



  • Afternoon all,

    Im hoping that someone will be able to point me in the right direction. I have been asked to make a change to a silverlight application today - I dont normally work with silverlight and am having a bit of an issue.

    What I have is a collection List<FeedbackHeaders> this is being set as the itemSource on an ItemsControl (repeater)
    Within the repeating control I have another control which requires a FeedbackHeader to be passed to it as a paramater (Public FeedbackHeader CurrentFeedbackHeader{get;set;})

    My XAML looks a bit like this:

    <FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas>

    <</FONT></FONT></FONT><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas>ItemsControl</FONT></FONT></FONT><FONT color=#ff0000 size=2 face=Consolas><FONT color=#ff0000 size=2 face=Consolas><FONT color=#ff0000 size=2 face=Consolas> ItemsSource</FONT></FONT></FONT><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas>="{</FONT></FONT></FONT><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas>Binding</FONT></FONT></FONT><FONT color=#ff0000 size=2 face=Consolas><FONT color=#ff0000 size=2 face=Consolas><FONT color=#ff0000 size=2 face=Consolas> Path</FONT></FONT></FONT><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas>=CurrentHeaders,</FONT></FONT></FONT><FONT color=#ff0000 size=2 face=Consolas><FONT color=#ff0000 size=2 face=Consolas><FONT color=#ff0000 size=2 face=Consolas> Mode</FONT></FONT></FONT><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas>=TwoWay}" >

    </FONT></FONT></FONT><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas>

    </FONT></FONT></FONT><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas>  <</FONT></FONT></FONT><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas>ItemsControl.ItemTemplate</FONT></FONT></FONT><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas>>

    </FONT></FONT></FONT><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas>

    </FONT></FONT></FONT><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas>    <</FONT></FONT></FONT><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas>DataTemplate</FONT></FONT></FONT><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas>>

    </FONT></FONT></FONT><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas></FONT></FONT></FONT><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas>       <</FONT></FONT></FONT><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas>fb</FONT></FONT></FONT><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas>:</FONT></FONT></FONT><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas>FeedbackDetailEntry</FONT></FONT></FONT><FONT color=#ff0000 size=2 face=Consolas><FONT color=#ff0000 size=2 face=Consolas><FONT color=#ff0000 size=2 face=Consolas> CurrentFeedbackHeader</FONT></FONT></FONT><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas>="{</FONT></FONT></FONT><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas>WHAT DO I PUT HERE ?????????</FONT></FONT></FONT><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas>}" /></FONT></FONT></FONT><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas> </FONT></FONT></FONT></FONT></FONT></FONT><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas>

    </FONT></FONT></FONT><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas>    </</FONT></FONT></FONT><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas>DataTemplate</FONT></FONT></FONT><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas>>

    </FONT></FONT></FONT><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas>

    </FONT></FONT></FONT><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas>  </</FONT></FONT></FONT><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas>ItemsControl.ItemTemplate</FONT></FONT></FONT><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas>>

    </FONT></FONT></FONT><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas>

    </FONT></FONT></FONT><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas></</FONT></FONT></FONT><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas>ItemsControl</FONT></FONT></FONT><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas>></FONT></FONT></FONT>

    <FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas></FONT></FONT></FONT> 

    <FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas>Does anyone know what I need to to to pass the feedbackHeader that is bound to the row through to the CurrentFeedbackHeader property of the FeedbackDetailEntry Control?

    Its driving me insane - Im certian that its going to be simple.</FONT></FONT></FONT>

    <FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas></FONT></FONT></FONT> 

    <FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas>Any help appreciated.</FONT></FONT></FONT>

    <FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas></FONT></FONT></FONT> 

    <FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas>Thanks

    </FONT></FONT></FONT>


  •  <font color="#0000ff" size="2" face="Consolas"><font color="#0000ff" size="2" face="Consolas"><font color="#0000ff" size="2" face="Consolas"><</font></font></font><font color="#a31515" size="2" face="Consolas"><font color="#a31515" size="2" face="Consolas"><font color="#a31515" size="2" face="Consolas">fb</font></font></font><font color="#0000ff" size="2" face="Consolas"><font color="#0000ff" size="2" face="Consolas"><font color="#0000ff" size="2" face="Consolas">:</font></font></font><font color="#a31515" size="2" face="Consolas"><font color="#a31515" size="2" face="Consolas"><font color="#a31515" size="2" face="Consolas">FeedbackDetailEntry</font></font></font><font color="#ff0000" size="2" face="Consolas"><font color="#ff0000" size="2" face="Consolas"><font color="#ff0000" size="2" face="Consolas"> CurrentFeedbackHeader</font></font></font><font color="#0000ff" size="2" face="Consolas"><font color="#0000ff" size="2" face="Consolas"><font color="#0000ff" size="2" face="Consolas">="{</font></font></font><font color="#a31515" size="2" face="Consolas"><font color="#a31515" size="2" face="Consolas"><font color="#a31515" size="2" face="Consolas">Binding</font></font></font><font color="#0000ff" size="2" face="Consolas"><font color="#0000ff" size="2" face="Consolas"><font color="#0000ff" size="2" face="Consolas">}" /></font></font></font>

     This will bind each FeedbackDetailEntry to the FeedbackHeader object (taken from the ItemsSource in the ItemsControl) that it was created for.



  • Thanks thats put me on the right path, however Im now getting this:


    Message: Unhandled Error in Silverlight Application
    Code: 4004   
    Category: ManagedRuntimeError      
    Message: System.Windows.Markup.XamlParseException: Set property 'HireServicesShoppingCart.Controls.Feedback.FeedbackDetailEntry.CurrentFeedbackHeader' threw an exception. [Line: 30 Position: 75] --->

    System.ArgumentException: Object of type 'System.Windows.Data.Binding' cannot be converted to type 'HireServicesShoppingCart.Web.Models.Shared.FeedbackHeader'.

    Any ideas what might be causing this?



  • Sorted, Needed a Dependancy property.

    Thanks


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.