I have two Silverlight controls in my project, both have TeamId properties. I would like to bundle them together in XAML in control hosting as user controls similar to:
<agChat:UserTeams x:Name="oUserTeams" />
<agChat:OnlineUser x:Name="oOnlineUsers" TeamId="{Binding ElementName=oUserTeams, Path=TeamId}" />
In the first control, I implement System.ComponentModel.INotifyPropertyChanged and raise the PropertyChanged event after changing the TeamId property.
In the second control, I used the propdp fragment to define the TeamId property as Dependency.
public static readonly DependencyProperty TeamIdProperty =
DependencyProperty.Register(
"TeamId",
typeof(string),
typeof(OnlineUsers),
new System.Windows.PropertyMetadata(new System.Windows.PropertyChangedCallback(TeamChanged)));
However, when silverlight controls are first created, I get the following exception from Silverlight:
Unhandled Error in Silverlight 2 Application Invalid attribute value {Binding ElementName=oUserTeams, Path=TeamId} for property TeamId. [Line: 21 Position: 146] at System.Windows.Application.LoadComponent(Object component, Uri xamlUri) at agChat.Page.InitializeComponent() at agChat.Page..ctor() at agChat.App.Application_Startup(Object sender, StartupEventArgs e) at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args) at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
Any ideas what I'm doing wrong? Obviously, all this could be done in code, but this seems like the right approach.