ComboBox Data Binding in XAML<p>Hi<br><br>The ComboBox data binding is on a DataTable which is returned from a method call on a singleton instance object.<br><br>Here is my XAML<br><br><font color="#0000ff" size=2></p> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px"></font><font style="color:blue">&lt;</font><font style="font-size:11px">Window x:</font><font style="color:red">Class</font><font style="font-size:11px">=</font><font style="color:blue">&quot;MainWindow&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:red">xmlns</font><font style="font-size:11px">=</font><font style="color:blue">http</font><font style="font-size:11px">://schemas.microsoft.com/winfx/2006/xaml/presentation  </font></td></tr> <tr> <td>    xmlns:</font><font style="color:red">x</font><font style="font-size:11px">=</font><font style="color:blue">http</font><font style="font-size:11px">://schemas.microsoft.com/winfx/2006/xaml  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    xmlns:</font><font style="color:red">data</font><font style="font-size:11px">=</font><font style="color:blue">&quot;clr-namespace:System.Data;assembly=System.Data&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>    </font><font style="color:red">Title</font><font style="font-size:11px">=</font><font style="color:blue">&quot;Database&quot;</font><font style="font-size:11px"> </font><font style="color:red">Height</font><font style="font-size:11px">=</font><font style="color:blue">&quot;495&quot;</font><font style="font-size:11px"> </font><font style="color:red">Width</font><font style="font-size:11px">=</font><font style="color:blue">&quot;420&quot;</font><font style="font-size:11px"> </font><font style="color:red">ResizeMode</font><font style="font-size:11px">=</font><font style="color:blue">&quot;CanResizeWithGrip&quot;</font><font style="font-size:11px">&gt;  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:blue">&lt;</font><font style="font-size:11px">Window.Resources</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>        </font><font style="color:blue">&lt;</font><font style="font-size:11px">ObjectDataProvider x:</font><font style="color:red">Key</font><font style="font-size:11px">=</font><font style="color:blue">&quot;DataTable&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">            </font><font style="color:red">ObjectType</font><font style="font-size:11px">=</font><font style="color:blue">&quot;{x:Type data:Sql.SqlDataSourceEnumerator}&quot;</font><font style="font-size:11px">/&gt;   </font></td></tr> <tr> <td>    </font><font style="color:blue">&lt;/</font><font style="font-size:11px">Window.Resources</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:blue">&lt;</font><font style="font-size:11px">StackPanel</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>        </font><font style="color:blue">&lt;</font><font style="font-size:11px">ComboBox </font><font style="color:red">Name</font><font style="font-size:11px">=</font><font style="color:blue">&quot;comboBoxServer&quot;</font><font style="font-size:11px">   </font></td></tr> <tr> <td style="background-color:#f7f7f7">            </font><font style="color:red">ItemsSource</font><font style="font-size:11px">=&quot;{Binding </font><font style="color:red">Source</font><font style="font-size:11px">=  </font></td></tr> <tr> <td>                {x:Static data:Sql.SqlDataSourceEnumerator.Instance}}&quot;   </td></tr> <tr> <td style="background-color:#f7f7f7">            </font><font style="color:red">DisplayMemberPath</font><font style="font-size:11px">=</font><font style="color:blue">&quot;ServerName&quot;</font><font style="font-size:11px"> </font><font style="color:blue">/&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>    </font><font style="color:blue">&lt;/</font><font style="font-size:11px">StackPanel</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">&lt;/</font><font style="font-size:11px">Window</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td> </td></tr></tbody></table></div><br><font color="#000000">The method I want to call is GetDataSources(), for example in code it would appears:<br></font><br> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px">System.Data.Sql.SqlDataSourceEnumerator.Instance.GetDataSources();</font></td></tr></tbody></table></div><br><font color="#000000">So the question is, how do I declarative make this call using XAML binding the return DataTable to a ComboBox?<br></font><br>Craig<br><br></font>© 2009 Microsoft Corporation. All rights reserved.Sat, 04 Jul 2009 22:34:50 Zbf263146-47b4-482d-82dd-96c96a18ad37http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/bf263146-47b4-482d-82dd-96c96a18ad37#bf263146-47b4-482d-82dd-96c96a18ad37http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/bf263146-47b4-482d-82dd-96c96a18ad37#bf263146-47b4-482d-82dd-96c96a18ad37Forum Craighttp://social.msdn.microsoft.com/Profile/en-US/?user=Forum%20CraigComboBox Data Binding in XAML<p>Hi<br><br>The ComboBox data binding is on a DataTable which is returned from a method call on a singleton instance object.<br><br>Here is my XAML<br><br><font color="#0000ff" size=2></p> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px"></font><font style="color:blue">&lt;</font><font style="font-size:11px">Window x:</font><font style="color:red">Class</font><font style="font-size:11px">=</font><font style="color:blue">&quot;MainWindow&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:red">xmlns</font><font style="font-size:11px">=</font><font style="color:blue">http</font><font style="font-size:11px">://schemas.microsoft.com/winfx/2006/xaml/presentation  </font></td></tr> <tr> <td>    xmlns:</font><font style="color:red">x</font><font style="font-size:11px">=</font><font style="color:blue">http</font><font style="font-size:11px">://schemas.microsoft.com/winfx/2006/xaml  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    xmlns:</font><font style="color:red">data</font><font style="font-size:11px">=</font><font style="color:blue">&quot;clr-namespace:System.Data;assembly=System.Data&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>    </font><font style="color:red">Title</font><font style="font-size:11px">=</font><font style="color:blue">&quot;Database&quot;</font><font style="font-size:11px"> </font><font style="color:red">Height</font><font style="font-size:11px">=</font><font style="color:blue">&quot;495&quot;</font><font style="font-size:11px"> </font><font style="color:red">Width</font><font style="font-size:11px">=</font><font style="color:blue">&quot;420&quot;</font><font style="font-size:11px"> </font><font style="color:red">ResizeMode</font><font style="font-size:11px">=</font><font style="color:blue">&quot;CanResizeWithGrip&quot;</font><font style="font-size:11px">&gt;  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:blue">&lt;</font><font style="font-size:11px">Window.Resources</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>        </font><font style="color:blue">&lt;</font><font style="font-size:11px">ObjectDataProvider x:</font><font style="color:red">Key</font><font style="font-size:11px">=</font><font style="color:blue">&quot;DataTable&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">            </font><font style="color:red">ObjectType</font><font style="font-size:11px">=</font><font style="color:blue">&quot;{x:Type data:Sql.SqlDataSourceEnumerator}&quot;</font><font style="font-size:11px">/&gt;   </font></td></tr> <tr> <td>    </font><font style="color:blue">&lt;/</font><font style="font-size:11px">Window.Resources</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:blue">&lt;</font><font style="font-size:11px">StackPanel</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>        </font><font style="color:blue">&lt;</font><font style="font-size:11px">ComboBox </font><font style="color:red">Name</font><font style="font-size:11px">=</font><font style="color:blue">&quot;comboBoxServer&quot;</font><font style="font-size:11px">   </font></td></tr> <tr> <td style="background-color:#f7f7f7">            </font><font style="color:red">ItemsSource</font><font style="font-size:11px">=&quot;{Binding </font><font style="color:red">Source</font><font style="font-size:11px">=  </font></td></tr> <tr> <td>                {x:Static data:Sql.SqlDataSourceEnumerator.Instance}}&quot;   </td></tr> <tr> <td style="background-color:#f7f7f7">            </font><font style="color:red">DisplayMemberPath</font><font style="font-size:11px">=</font><font style="color:blue">&quot;ServerName&quot;</font><font style="font-size:11px"> </font><font style="color:blue">/&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>    </font><font style="color:blue">&lt;/</font><font style="font-size:11px">StackPanel</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">&lt;/</font><font style="font-size:11px">Window</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td> </td></tr></tbody></table></div><br><font color="#000000">The method I want to call is GetDataSources(), for example in code it would appears:<br></font><br> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px">System.Data.Sql.SqlDataSourceEnumerator.Instance.GetDataSources();</font></td></tr></tbody></table></div><br><font color="#000000">So the question is, how do I declarative make this call using XAML binding the return DataTable to a ComboBox?<br></font><br>Craig<br><br></font>Tue, 10 Feb 2009 03:22:29 Z2009-02-10T03:22:29Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/bf263146-47b4-482d-82dd-96c96a18ad37#80124431-cd48-42ab-bac7-83e99bb5dbb1http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/bf263146-47b4-482d-82dd-96c96a18ad37#80124431-cd48-42ab-bac7-83e99bb5dbb1IrfanAhmadhttp://social.msdn.microsoft.com/Profile/en-US/?user=IrfanAhmadComboBox Data Binding in XAML Read the following article;<br><br><a href="http://msdn.microsoft.com/en-us/library/aa348824.aspx">http://msdn.microsoft.com/en-us/library/aa348824.aspx</a><hr class="sig">Irfan AhmadTue, 10 Feb 2009 06:58:59 Z2009-02-10T06:58:59Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/bf263146-47b4-482d-82dd-96c96a18ad37#96bed7d3-baed-4dc7-bed6-956d57d2ac53http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/bf263146-47b4-482d-82dd-96c96a18ad37#96bed7d3-baed-4dc7-bed6-956d57d2ac53Forum Craighttp://social.msdn.microsoft.com/Profile/en-US/?user=Forum%20CraigComboBox Data Binding in XAML <strong>Solution</strong><br><br> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px"></font><font style="color:blue">&lt;</font><font style="font-size:11px">Window x:</font><font style="color:red">Class</font><font style="font-size:11px">=</font><font style="color:blue">&quot;MainWindow&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:red">xmlns</font><font style="font-size:11px">=</font><font style="color:blue">&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>    xmlns:</font><font style="color:red">x</font><font style="font-size:11px">=</font><font style="color:blue">&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">    xmlns:</font><font style="color:red">data</font><font style="font-size:11px">=</font><font style="color:blue">&quot;clr-namespace:System.Data;assembly=System.Data&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>    </font><font style="color:red">Title</font><font style="font-size:11px">=</font><font style="color:blue">&quot;Database&quot;</font><font style="font-size:11px"> </font><font style="color:red">Height</font><font style="font-size:11px">=</font><font style="color:blue">&quot;495&quot;</font><font style="font-size:11px"> </font><font style="color:red">Width</font><font style="font-size:11px">=</font><font style="color:blue">&quot;420&quot;</font><font style="font-size:11px"> </font><font style="color:red">ResizeMode</font><font style="font-size:11px">=</font><font style="color:blue">&quot;CanResizeWithGrip&quot;</font><font style="font-size:11px">&gt;  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:blue">&lt;</font><font style="font-size:11px">Window.Resources</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>        </font><font style="color:blue">&lt;</font><font style="font-size:11px">ObjectDataProvider   </font></td></tr> <tr> <td style="background-color:#f7f7f7">            x:</font><font style="color:red">Key</font><font style="font-size:11px">=</font><font style="color:blue">&quot;DataTable&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>            </font><font style="color:red">ObjectInstance</font><font style="font-size:11px">=</font><font style="color:blue">&quot;{x:Static data:Sql.SqlDataSourceEnumerator.Instance}&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">            </font><font style="color:red">MethodName</font><font style="font-size:11px">=</font><font style="color:blue">&quot;GetDataSources&quot;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>            </font><font style="color:red">IsAsynchronous</font><font style="font-size:11px">=</font><font style="color:blue">&quot;True&quot;</font><font style="font-size:11px">/&gt;         </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:blue">&lt;/</font><font style="font-size:11px">Window.Resources</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td></font><font style="color:blue">&lt;</font><font style="font-size:11px">StackPanel</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7">                </font><font style="color:blue">&lt;</font><font style="font-size:11px">ComboBox </font><font style="color:red">ItemsSource</font><font style="font-size:11px">=</font><font style="color:blue">&quot;{Binding Source={StaticResource DataTable}, Mode=OneWay}&quot;</font><font style="font-size:11px"> </font><font style="color:red">DisplayNamePath</font><font style="font-size:11px">=</font><font style="color:blue">&quot;ServerName&quot;</font><font style="font-size:11px">/&gt;  </font></td></tr> <tr> <td></font><font style="color:blue">&lt;/</font><font style="font-size:11px">StackPanel</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">&lt;/</font><font style="font-size:11px">Window</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr></tbody></table></div>Tue, 10 Feb 2009 07:05:07 Z2009-02-10T07:05:07Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/bf263146-47b4-482d-82dd-96c96a18ad37#e3d30ad8-e167-4419-b542-f3489c9dbfa8http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/bf263146-47b4-482d-82dd-96c96a18ad37#e3d30ad8-e167-4419-b542-f3489c9dbfa8IrfanAhmadhttp://social.msdn.microsoft.com/Profile/en-US/?user=IrfanAhmadComboBox Data Binding in XAML Yes, that is what explained in the article I had pointed in my last post :-(<hr class="sig">Irfan AhmadTue, 10 Feb 2009 09:39:17 Z2009-02-10T09:39:17Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/bf263146-47b4-482d-82dd-96c96a18ad37#8bd4e4a2-387f-400d-954e-d4020c3e00dahttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/bf263146-47b4-482d-82dd-96c96a18ad37#8bd4e4a2-387f-400d-954e-d4020c3e00daInvestor5555http://social.msdn.microsoft.com/Profile/en-US/?user=Investor5555ComboBox Data Binding in XAMLThis works great, but being new to WPF and how to bind, I am wondering if there is a way to know when this process is complete. <br/> <br/> Basically, I want to know if there is a way (BackgroundWorker, for example) to know when the asynchronous method is complete so I can enable other UI controls. <br/> How would I be able to use XAML to tie WorkerSupportsCancellation=&quot;True&quot; and cancel this request?<br/> <br/> Also, what if I wanted the data to go directly to a model, wait for completion, and then update the combobox? <br/> <br/> <br/>Sat, 04 Jul 2009 22:34:49 Z2009-07-04T22:34:49Z