Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What I believe you're looking for is a combination of DataBinding and DataTemplating. DataTemplating will allow you to define different visual elements for different business objects (in this case <code>MyBooleanSettings</code> and <code>MyStringSettings</code>. DataBinding will allow the visual elements to update and be updated my the data in the business objects.</p> <p>Example (xaml):</p> <pre><code>&lt;Window DataContext={Binding RelativeSource={RelativeSource Self}}"&gt; &lt;Window.Resources&gt; &lt;DataTemplate DataType={x:Type local:MyObject}"&gt; &lt;TextBlock Text={Binding Title}" /&gt; &lt;ContentPresenter Content="{Binding Settings}" /&gt; &lt;/DataTemplate&gt; &lt;DataTemplate DataType={x:Type local:MyObject}"&gt; &lt;TextBox Text={Binding &lt;/DataTemplate&gt; &lt;DataTemplate DataType={x:Type local:MyBoolSettings}&gt; &lt;CheckBox IsChecked="{Binding BoolSetting}" /&gt; &lt;/DataTemplate&gt; &lt;DataTemplate DataType={x:Type local:MyStringSettings}&gt; &lt;TextBox Text="{Binding StringSetting}" /&gt; &lt;/DataTemplate&gt; &lt;/Window.Resources&gt; &lt;ContentPresenter Content="{Binding ObjectToEdit}" /&gt; &lt;/Window&gt; </code></pre> <p>Then in the code behind define:</p> <pre><code>public MyObject ObjectToEdit { get; set; } </code></pre> <p>Finally update your objects:</p> <pre><code>public class MySettings : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(sting s) { if(PropertyChanged != null) { PropertyChanged(s); } } } public class BoolSettings : MySettings { bool _value; bool BoolSetting { get { return _value; } set { if(_value != value) { _value = value; OnPropertyChanged("BoolSetting"); } } } } </code></pre> <p><strong>If however you really need to control when the view and object sync you should use the <code>UpdateSourceTrigger</code> property on the corresponding bindings.</strong></p> <p>If you want some additional reading I recommend: <a href="http://msdn.microsoft.com/en-us/library/ms752347.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms752347.aspx</a></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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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