Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Update ViewModel's data without recompiling the application?

$
0
0

xaml.cs ------------------------------------------------

public partial class Window1 : Window
{
public Window1()      
{
InitializeComponent();
DataContext = new ComboBoxPatterns();
}

ComboBoxPatterns.cs ----------------------------------

public class ComboBoxPatterns
 {
public List<string> Collection1 { get; set; }

public List<string> Collection2 { get; set; } 
public ComboBoxPatterns()
{
Collection1 = new List<string>()
 {
     "Whatever",
     "Whatever",
 };

Collection2 = new List<string>() {
     "Whatever2",
     "Whatever2",
 };

xaml --------------------------------------------

<ComboBox
ItemsSource="{Binding Collection1}"/>
<TextBox
Text="{Binding Collection2}" />

I often have to add new entries to Collection1 and Collection2. 

So far, I've just added the new entries manually and recompile the application to make the new entries available.

My question is, is there a way to make changes and make them available without recompiling the application?


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>