Forums - C# Corner

Forum guidelines

C# WPF: How to get UserControl from MainWindow?

Dec 7 2017 5:09 AM
I made a small App in WPF. This is a drawing tool.
My chef decided to integrate my app in the existing software of our company
and I'm now a little bit stuck because I haven't used yet any UserControl beucause it was supposed to be an "independant" App.
Now the question:
Can I change the existing MainWindow.xaml in UserControl?
 What I mean is:
       DataContext="MainViewModel" x:Class="Skizzen_Editor.MainWindow"
      Name="Win_SkizzenEditor" Background="Transparent"
here I've just changed <Window> in <UserControl>
but something is going wrong. It seems It doenst work.
Can you please suggest me a solution?
Or is it better to make a new UserControl and out the existing MainWindow.xaml inside of it? 
Thanks in advance 

Answers (2)