{
_dialogService.ShowDialog
(this, result =>
{
var test = result;
});
}
< /code>
public List protocols = new List { "Option 1", "Option 2" };
< /code>
DialogService
The ShowDialog function passes the calling viewmodel reference to an internal function to provide the appropriate datacontext.
private static void ShowDialogInternal(ViewModel vmDataContext, Type type, Action callback)
{
var dialog = new DialogWindow();
EventHandler closeEventHandler = null;
closeEventHandler = (s, e) =>
{
callback(dialog.DialogResult.ToString());
dialog.Closed -= closeEventHandler;
};
dialog.Closed += closeEventHandler;
var content = Activator.CreateInstance(type);
(content as FrameworkElement).DataContext = vmDataContext;
dialog.Content = content;
dialog.ShowDialog();
}
< /code>
XAML
This is the dialog content that should have the right datacontext
< /code>
I am able to see that the appropriate datacontext is set for the dialog

Подробнее здесь: https://stackoverflow.com/questions/797 ... context-be
Мобильная версия