<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Hierarachical Related Binding</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Hierarachical Related Binding</description>
  <pubDate>Mon, 13 Apr 2026 06:59:43 -700</pubDate>
  <lastBuildDate>Fri, 21 Jan 2011 12:54:27 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=2456</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Hierarachical Related Binding : Hi quest202;The CheckBox IsChecked...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2456&amp;PID=9743#9743</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 2456<br /><strong>Posted:</strong> 21-Jan-2011 at 12:54pm<br /><br />Hi quest202;<div><br></div><div>The CheckBox IsChecked property is a boolean and as such it needs to be binded to a boolean property as well.</div><div><br></div><div>To get the Report's related entities of the Mapping records, you can do a logic similar to the following:</div><div><br></div><div>//Note that this works because you have .Include("Mappings") in your query. This line will throw an exception if you //haven't.</div><div>var mappings = Reports&#091;0&#093;.Mappings;</div><div><br></div><div>Then you can do some business logic with the mappings and assign a public boolean property that will be binded to the CheckBox IsChecked property. For example:</div><div><br></div><div>View:</div><div><br></div><div><span ="Apple-style-span" style="font-family: C&#111;nsolas; line-height: normal; font-size: 13px; -webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><b><span style="color: red; ">&lt;CheckBox x:Name="chkThreat" IsChecked="{Binding IsChecked}" /&gt;</span></b></span></div><div><span ="Apple-style-span" style="font-family: C&#111;nsolas; line-height: normal; font-size: 13px; -webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><b><span style="color: red; "><br></span></b></span></div><div><font ="Apple-style-span" color="#FF0000" face="C&#111;nsolas" size="2"><span ="Apple-style-span" style="line-height: normal; -webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><b><span ="Apple-style-span" style="color: rgb0, 0, 0; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: normal; -webkit-border-horiz&#111;ntal-spacing: 0px; -webkit-border-vertical-spacing: 0px; font-size: 12px; line-height: 16px; ">ViewModel:</span></b></span></font></div><div><span ="Apple-style-span" style="font-family: C&#111;nsolas; line-height: normal; font-size: 13px; -webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><b><span style="color: red; "><br></span></b></span></div><div>public bool IsChecked {</div><div><span ="Apple-tab-span" style="white-space:pre">	</span>get {</div><div><span ="Apple-tab-span" style="white-space:pre">		</span>return _isChecked;</div><div><span ="Apple-tab-span" style="white-space:pre">	</span>}</div><div><span ="Apple-tab-span" style="white-space:pre">	</span>set {</div><div><span ="Apple-tab-span" style="white-space:pre">		</span>_isChecked = value;</div><div><span ="Apple-tab-span" style="white-space:pre">		</span>RaisePropertyChanged("IsChecked");</div><div><span ="Apple-tab-span" style="white-space:pre"></span><span ="Apple-tab-span" style="white-space:pre">	</span>}</div><div>}</div><div><br></div><div>private bool _isChecked;</div><div><br></div><div>private void DoSomeLogicWithMappings(object&#091;&#093; mappings) {</div><div><span ="Apple-tab-span" style="white-space:pre">	</span>..............</div><div><span ="Apple-tab-span" style="white-space:pre">	</span>_isChecked = true;</div><div><span ="Apple-tab-span" style="white-space:pre">	</span>................</div><div>}</div><div><br></div><div>Your implementation can be very much different from this. I'm just illustrating how to get the related entities and how to bind to the CheckBox IsChecked property.</div><div><br></div><div>Hope this helps.</div>]]>
   </description>
   <pubDate>Fri, 21 Jan 2011 12:54:27 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2456&amp;PID=9743#9743</guid>
  </item> 
  <item>
   <title>Hierarachical Related Binding : I have an Incident Report data...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2456&amp;PID=9732#9732</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1052" rel="nofollow">quest202</a><br /><strong>Subject:</strong> 2456<br /><strong>Posted:</strong> 20-Jan-2011 at 5:57pm<br /><br /><P style="MARGIN: 0in 0in 10pt" =Ms&#111;normal><FONT size=3><FONT face=Calibri>I have an Incident Report data form which also lists all possible threat types for user to choose for this Incident Report.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The threat types are in Threat table which is hierarchical categorized with parent-child relationship.<?: prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT></FONT></P><P style="MARGIN: 0in 0in 10pt" =Ms&#111;normal><FONT size=3><FONT face=Calibri>So I have 3 tables. <o:p></o:p></FONT></FONT></P><P style="MARGIN: 0in 0in 10pt" =Ms&#111;normal><FONT size=3><FONT face=Calibri>The Incident Report table consists of fields: ReportID (primary,unique), Title, Story….<o:p></o:p></FONT></FONT></P><P style="MARGIN: 0in 0in 10pt" =Ms&#111;normal><FONT size=3><FONT face=Calibri>The Threat table consists of fields: ThreatID (primary,unique),<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>ParentThreatID, Name ….<o:p></o:p></FONT></FONT></P><P style="MARGIN: 0in 0in 10pt" =Ms&#111;normal><FONT size=3><FONT face=Calibri>The third table tied the above 2 tables together.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>I called it the Mapping table.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The Mapping table consists of fields: MappingID (primary,unique), ReportID, and ThreatID.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The purpose of the Mapping table is to keep track of the threat types assigned to a report. <o:p></o:p></FONT></FONT></P><P style="MARGIN: 0in 0in 10pt" =Ms&#111;normal><FONT size=3><FONT face=Calibri>In my ViewModel, I have the following in the constructor:<o:p></o:p></FONT></FONT></P><P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne" =Ms&#111;normal><SPAN style="FONT-FAMILY: C&#111;nsolas; FONT-SIZE: 9.5pt">Reports = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">ObservableCollection</SPAN>&lt;<SPAN style="COLOR: #2b91af">Report</SPAN>&gt;();<o:p></o:p></SPAN></P><P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne" =Ms&#111;normal><SPAN style="FONT-FAMILY: C&#111;nsolas; COLOR: blue; FONT-SIZE: 9.5pt">var</SPAN><SPAN style="FONT-FAMILY: C&#111;nsolas; FONT-SIZE: 9.5pt"> query = _mgr.Reports.Include(<SPAN style="COLOR: #a31515">"Mappings"</SPAN>);<o:p></o:p></SPAN></P><P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne" =Ms&#111;normal><SPAN style="FONT-FAMILY: C&#111;nsolas; FONT-SIZE: 9.5pt">query.ExecuteAsync(op =&gt; op.Results.ForEach(<SPAN style="COLOR: blue">this</SPAN>.Reports.Add));<o:p></o:p></SPAN></P><FONT size=3><FONT face=Calibri><DIV>&nbsp;</DIV><DIV>I am able to display the Incident Report DataForm and all possible Threat types from the Threat table in a tree view (HierachicalDataTemplate), and I put checkboxes in front of the tree item.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>My problem is now I need to check the box of the appropriate Threat if the ReportID existed in the Mapping table.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Furthermore, if the ReportID for the Threat does not exist in the Mapping table, I need to add a new record to the Mapping table to keep track of it.<o:p></o:p></FONT></FONT></DIV><P style="MARGIN: 0in 0in 10pt" =Ms&#111;normal><FONT size=3><FONT face=Calibri>I am not sure how to get to the Report’s related entities of the Mapping records, and assigned them to the checkboxes.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN><o:p></o:p></FONT></FONT></P><P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne" =Ms&#111;normal><SPAN style="FONT-FAMILY: C&#111;nsolas; FONT-SIZE: 9.5pt">&lt;sdk:TreeView x:Name="treeThreats" itemsSource="{Binding Threats,Source={StaticResource vm}}" &gt;<o:p></o:p></SPAN></P><P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne" =Ms&#111;normal><SPAN style="FONT-FAMILY: C&#111;nsolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;sdk:TreeView.ItemTemplate&gt;<o:p></o:p></SPAN></P><P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne" =Ms&#111;normal><SPAN style="FONT-FAMILY: C&#111;nsolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;winControls:HierarchicalDataTemplate ItemsSource="{Binding ChildThreats}" &gt;<o:p></o:p></SPAN></P><P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne" =Ms&#111;normal><SPAN style="FONT-FAMILY: C&#111;nsolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;StackPanel Orientation="Horizontal"&gt;<o:p></o:p></SPAN></P><P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne" =Ms&#111;normal><SPAN style="FONT-FAMILY: C&#111;nsolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><B style="mso-bidi-font-weight: normal"><SPAN style="COLOR: red">&lt;CheckBox x:Name="chkThreat" IsChecked="{Binding Mappings, Source={StaticResource vm}}" /&gt;<o:p></o:p></SPAN></B></SPAN></P><P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne" =Ms&#111;normal><SPAN style="FONT-FAMILY: C&#111;nsolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;TextBlock Text="{Binding Name, Mode=OneWay}" Margin="5,0" /&gt;<o:p></o:p></SPAN></P><P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne" =Ms&#111;normal><SPAN style="FONT-FAMILY: C&#111;nsolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/StackPanel&gt;<o:p></o:p></SPAN></P><P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne" =Ms&#111;normal><SPAN style="FONT-FAMILY: C&#111;nsolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/winControls:HierarchicalDataTemplate&gt;<o:p></o:p></SPAN></P><P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne" =Ms&#111;normal><SPAN style="FONT-FAMILY: C&#111;nsolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/sdk:TreeView.ItemTemplate&gt;<o:p></o:p></SPAN></P><P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne" =Ms&#111;normal><SPAN style="FONT-FAMILY: C&#111;nsolas; FONT-SIZE: 9.5pt">&lt;/sdk:TreeView&gt;<o:p></o:p></SPAN></P><P style="MARGIN: 0in 0in 10pt" =Ms&#111;normal><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P><P style="MARGIN: 0in 0in 10pt" =Ms&#111;normal><FONT size=3><FONT face=Calibri>Thank you for your help<o:p></o:p></FONT></FONT></P>]]>
   </description>
   <pubDate>Thu, 20 Jan 2011 17:57:32 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2456&amp;PID=9732#9732</guid>
  </item> 
 </channel>
</rss>