private void BuildSearchToolWindow() { if (toolPickerUC == null) { toolPickerUC = new searchTool(); toolPicker_VM = toolPickerUC.DataContext as searchTool_ModelView; } toolPickerWindow = new Window() { Content = toolPickerUC, Title = "Gép választó", SizeToContent = SizeToContent.WidthAndHeight }; toolPicker_VM.ToolSelected += (s, a) => { ToolRepresentation tool = s as ToolRepresentation; tool.ValidationRules = new ToolValidationRules(); viewModel.selectedTool = tool; toolPickerWindow.Hide(); }; }