Sign in to follow this  

WPF : Separation of UI from Data

Recommended Posts

If you were to use Datatemplates to separate UI from data, such as the following -

namespace WpfApplication1
partial class Data
public string SomeData { get; set; }
public partial class MainWindow : Window
public MainWindow()
Data d = new Data();
d.SomeData = "SomeValue";
Content = d;
<ResourceDictionary xmlns=""
<DataTemplate DataType="{x:Type local:Data}">
<Button Content="{Binding Path=SomeData}"/>

How would you then handle events on that Data template? Say for example I wanted to perform some task on the SomeData property in response to the button being clicked.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this