Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs')
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs25
1 files changed, 17 insertions, 8 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs
index 2533d97..5fc2093 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs
@@ -1,4 +1,5 @@
using System;
+using System.Linq;
using AppKit;
using CoreGraphics;
using Xamarin.PropertyEditing.ViewModels;
@@ -19,11 +20,16 @@ namespace Xamarin.PropertyEditing.Mac
set {
if (this.viewModel != null) {
this.viewModel.PropertyChanged -= OnPropertyChanged;
+ if (this.viewModel.SupportsBindings)
+ this.viewModel.CreateBindingRequested -= OnBindingRequested;
}
this.viewModel = value;
+
if (this.viewModel != null) {
this.viewModel.PropertyChanged += OnPropertyChanged;
+ if (this.viewModel.SupportsBindings)
+ this.viewModel.CreateBindingRequested += OnBindingRequested;
ValueSourceChanged (this.viewModel.ValueSource);
}
}
@@ -110,16 +116,13 @@ namespace Xamarin.PropertyEditing.Mac
if (this.viewModel.SupportsBindings) {
this.popUpContextMenu.AddItem (NSMenuItem.SeparatorItem);
- var mi3 = new NSMenuItem (Properties.Resources.CreateDataBindingMenuItem) {
+ this.popUpContextMenu.AddItem (new CommandMenuItem (Properties.Resources.CreateDataBindingMenuItem, this.viewModel.RequestCreateBindingCommand) {
AttributedTitle = new Foundation.NSAttributedString (
Properties.Resources.CreateDataBindingMenuItem,
new CoreText.CTStringAttributes {
Font = new CoreText.CTFont (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize + 1),
})
- };
-
- mi3.Activated += OnBindingRequested;
- this.popUpContextMenu.AddItem (mi3);
+ });
}
this.popUpContextMenu.AddItem (NSMenuItem.SeparatorItem);
@@ -252,10 +255,16 @@ namespace Xamarin.PropertyEditing.Mac
resourceSelectorPopOver.Show (requestResourceView.Frame, (NSView)this, NSRectEdge.MinYEdge);
}
- private void OnBindingRequested (object sender, EventArgs e)
+ private void OnBindingRequested (object sender, CreateBindingRequestedEventArgs e)
{
- var bindingEditorWindow = new BindingEditorWindow (this.hostResources, this.viewModel);
- bindingEditorWindow.MakeKeyAndOrderFront (this);
+ var bindingEditorWindow = new BindingEditorWindow (this.hostResources, this.viewModel) {
+ Appearance = EffectiveAppearance,
+ };
+
+ var result = (NSModalResponse)(int)NSApplication.SharedApplication.RunModalForWindow (bindingEditorWindow);
+ if (result == NSModalResponse.OK) {
+ e.BindingObject = bindingEditorWindow.ViewModel.SelectedObjects.Single ();
+ }
}
}
}