summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls/ViewContainers/MultiBindingHack.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Controls/ViewContainers/MultiBindingHack.cs')
-rw-r--r--Xamarin.Forms.Controls/ViewContainers/MultiBindingHack.cs47
1 files changed, 47 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls/ViewContainers/MultiBindingHack.cs b/Xamarin.Forms.Controls/ViewContainers/MultiBindingHack.cs
new file mode 100644
index 00000000..4853fd14
--- /dev/null
+++ b/Xamarin.Forms.Controls/ViewContainers/MultiBindingHack.cs
@@ -0,0 +1,47 @@
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve (AllMembers = true)]
+ internal class MultiBindingHack : INotifyPropertyChanged
+ {
+ string _labelWithBounds;
+
+ public MultiBindingHack (VisualElement element)
+ {
+ LabelWithBounds = string.Format("{{X={0:0.00} Y={1:0.00} Width={2:0.00} Height={3:0.00}}}", element.X, element.Y, element.Width, element.Height);
+
+ element.PropertyChanged += (sender, args) => {
+ if (args.PropertyName == "X" ||
+ args.PropertyName == "Y" ||
+ args.PropertyName == "Width" ||
+ args.PropertyName == "Height" ||
+ args.PropertyName == "Rotation") {
+ LabelWithBounds = string.Format("{{X={0:0.00} Y={1:0.00} Width={2:0.00} Height={3:0.00}}}", element.X, element.Y, element.Width, element.Height); // super hack
+ }
+ };
+ }
+
+ public string LabelWithBounds
+ {
+ get { return _labelWithBounds; }
+ set
+ {
+ if (_labelWithBounds == value)
+ return;
+ _labelWithBounds = value;
+ OnPropertyChanged ();
+ }
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ void OnPropertyChanged ([CallerMemberName] string propertyName = null)
+ {
+ PropertyChangedEventHandler handler = PropertyChanged;
+ if (handler != null)
+ handler (this, new PropertyChangedEventArgs (propertyName));
+ }
+ }
+} \ No newline at end of file