Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom Attribute Binding in Silverlight
    primarykey
    data
    text
    <p>I've got two Silverlight Controls in my project, both have properties TeamId. I would like to bind these together in XAML in the control hosting both user controls similar to:</p> <pre><code> &lt;agChat:UserTeams x:Name="oUserTeams" /&gt; &lt;agChat:OnlineUser x:Name="oOnlineUsers" TeamId="{Binding ElementName=oUserTeams, Path=TeamId}" /&gt; </code></pre> <p>In the first control, I'm implementing System.ComponentModel.INotifyPropertyChanged and raising the PropertyChanged event upon the TeamId property changing.</p> <p>In the second control, I've used the propdp snippet to identify the TeamId as a Dependency property.</p> <pre><code> // Using a DependencyProperty as the backing store for TeamId. This enables animation, styling, binding, etc... public static readonly DependencyProperty TeamIdProperty = DependencyProperty.Register( "TeamId", typeof(string), typeof(OnlineUsers), new System.Windows.PropertyMetadata(new System.Windows.PropertyChangedCallback(TeamChanged))); </code></pre> <p>However when the silverlight controls first gets created, I get the follow exception from Silverlight:</p> <pre><code> 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) </code></pre> <p>Any ideas what I'm doing wrong? Obviously this could all be done in code-behind, but this <em>seems</em> like the correct approach.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload