Note that there are some explanatory texts on larger screens.

plurals
  1. POCan a XAML object be a source for one binding as well as a target for another binding?
    text
    copied!<p>Is it possible to have a TextBlock as a target and a source?</p> <p>Basically I have a bunch of entities which have simple relationships to other entities (like Entity1 Knows Entity3, Entity3 WorksAt Entity2 etc.)</p> <p>I have a <code>Link</code> class that stores <code>SourceEntity</code>, <code>Relationship</code> and <code>TargetEntity</code> details.</p> <p>What I want to be able to do is to select an entity then display the relationships related to that entity, with the target entities of each relationship listed underneath the relationship names. </p> <p>When an entity is selected, an <code>ObservableCollection</code> is populated with the <code>Links</code> for that particular entity (<code>SelectedEntityLinks&lt;Link&gt;</code>).</p> <p>Because each entity could have the same relationship to more than one target entity (Entity1 could know both Entity3 and Entity4 for eg.), I've created a method <code>GetThisRelationshipEntities()</code> that takes a relationship name as a parameter, looks through <code>SelectedEntityLinks</code> for relationship names that match the parameter, and returns an <code>ObservableCollection</code> with the target entities of that relationship.</p> <p>In my xaml I have a <code>WrapPanel</code> to display each relationship name in a TextBlock: </p> <pre><code>&lt;TextBlock x:Name="relationship" Text="{Binding Path=Relationship.Name}" /&gt; </code></pre> <p>Then underneath that another Textblock which should display the results of <code>GetThisRelationshipEntities(String relationshipName).</code> </p> <p>So I want the "relationship" TextBlock to both get its Text from the binding I've shown above, but also to provide its Text as a parameter to the <code>GetThisRelationshipEntities()</code> method which I've added to <code>&lt;UserControl.Resources&gt;</code> as an ObjectDataProvider.</p> <p>Sorry if this is a bit wordy but I hope it's clear. Any pointers/advice would be great.</p>
 

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