Jump to content
  • Advertisement
Sign in to follow this  

WPF : Separation of UI from Data

This topic is 2122 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!