Note that there are some explanatory texts on larger screens.

plurals
  1. POBinding via XAML or Code behind
    primarykey
    data
    text
    <p>I'm creating a WPF application and at the top of the page I need to display a postal address. Underneath the postal address will be product information. The product information is returned from a datasource and bound to the datacontext. eg this.DataContext = myComplexType;</p> <p>Staff need to manually switch which postal address is to be displayed. I think the best way would be to select would be via a radio button control. In other words, on my Page, I would have 3 radio buttons, *UK Address *USA Address *China Address and depending on which was selected, the appropriate text would be entered in the Textblock Name="txbPostalAddress" at the top of the page.</p> <p>The postal addresses live within a class called Addresses (as strings). e.g. Code:</p> <pre class="lang-cpp prettyprint-override"><code>namespace DAL { public class Addresses { public string GctHkAddress { get { return gctHkAddress;} } public string GctUsaAddress { get { return gctUsaAddress; } } public string GctUkAddress { get{return gctUkAddress;} } private string gctHkAddress = "Company Name\n Hong Kong \n"; private string gctUsaAddress = "Company Name\n USA \n"; private string gctUkAddress = "Company Name\n UK \n"; } } </code></pre> <p>My question is, should the binding be done in XAML or in code behind. I can do it in code behind quite easily but I get the feeling this negates the power of XAML. Does any one have any idea which is the better approach and if via XAML, any idea how or links to tutorials etc?</p> <p>Thanks</p> <p>Dave</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.
 

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