Answered Two-way binding with custom control

  • 29 พฤษภาคม 2549 12:35
     
     

    I've got a rather elaborate master-detail setup using a tabcontrol, a listcontrol and a custom control.

    I am using an objectdatasource with an observablecollection of RaceLines.  The tabs on the tabcontrol represent each RaceLine in the collection.  Each RaceLine has a collection of Races, which are presented on the panel (as a listcontrol) for each tab.  Each Race has a collection of CourseMarks which are displayed in a second listcontrol.

    The custom control has a dependency property called 'current race' which is bound to the selected item in first listcontrol.

    When i add a CourseMark to the customcontrol it updates the CurrentRace.CourseMarkCollection property, but this doesn't get updated on the first listcontrol so the second listcontrol doesn't update.

    I am binding to the custom control as follows

    <ChartControl ChartControl.CurrentRace="{Binding Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Path=RaceCollection/.}">

    Am I missing something?

ตอบทั้งหมด

  • 28 สิงหาคม 2549 20:12
     
     

    Have you tried binding a simple control (like a button) to the current item in your RaceCollection to make sure everything is being updated?

    Second, why are you using two-way binding?

    Third, RaceCollection is a collection that is a property on your data context, correct?

  • 29 สิงหาคม 2549 7:46
     
     คำตอบ

    Kevin,

    Thanks for the reply, I can't remember exactly what the problem was, but I think it was a typo in the xpath for the listcontrol.