jeudi 27 décembre 2018

How is this ViewModel linked to the UserControl? (The WPF Cefsharp Example)

For this Cefsharp.WPF.Example, can anyone tell where is the BrowserTabView linked to BrowserTabViewModel? https://github.com/cefsharp/CefSharp/blob/master/CefSharp.Wpf.Example/MainWindow.xaml

The basic concept of this application is easily understood: -- MainWindow.xaml lays out the application UI, including the TabControl. But each tab's content, which hosts a Cefsharp browser, is designed as a UserControl via BrowserTabView.xaml. -- Then there is the BrowserTabViewModel.cs to provide the properties for each tab. -- An ObservableCollection of ViewModels is created as ItemsSource for the MainWindow's TabControl, to make this application a multi-tabbed web browser.

Here is the piece of code in MainWindow.xaml that got me confused:

...... ...... .......
...... ......

  • Question: The part did not specify the UserControl. How does the program know that it's the BrowserTabView.xaml that should be here to give a view to BrowserTabViewModel? I read through the other xaml and cs codes, still did not find the link.

Another question is the {Binding} seems to bind the DataContext, which is the MainWindow itself, as is shown in MainWindow.xaml.cs. Does it make sense?




Aucun commentaire:

Enregistrer un commentaire