aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects/TemplatedControl.cs
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2015-09-15 01:38:48 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2015-09-15 01:38:48 +0200
commit8d543b42826995b35fdf8416e3a19fb4d3a0aa11 (patch)
treedfa1aa7048a963eb60a3ca45c9ea44621e8c0d94 /src/GraphicObjects/TemplatedControl.cs
parentba8da355cd2127e29b82745c4475ae2a9fbbdfa4 (diff)
Implement TemplatedWidth and TemplatedHeight PropertyLess bindings to
propagate sizing policy inside template
Diffstat (limited to 'src/GraphicObjects/TemplatedControl.cs')
-rw-r--r--src/GraphicObjects/TemplatedControl.cs44
1 files changed, 36 insertions, 8 deletions
diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs
index 37da50cf..ca3ed68c 100644
--- a/src/GraphicObjects/TemplatedControl.cs
+++ b/src/GraphicObjects/TemplatedControl.cs
@@ -60,14 +60,31 @@ namespace go
// set { _templatePath = value; }
// }
+ #region GraphicObject overrides
+ [XmlAttributeAttribute()][DefaultValue(-1)]
+ public override int Width {
+ get { return base.Width; }
+ set {
+ base.Width = value;
+ //PropertyLess binding for sizing policy in template
+ if (base.Width < 1) //send size policy to template elements
+ NotifyValueChanged ("TemplatedWidth", base.Width);
+ else //stretched in control if size is fixed
+ NotifyValueChanged ("TemplatedWidth", 0);
+ }
+ }
+ [XmlAttributeAttribute()][DefaultValue(-1)]
+ public override int Height {
+ get { return base.Height; }
+ set {
+ base.Height = value;
- protected virtual void loadTemplate(GraphicObject template = null)
- {
- if (template == null) {
- DefaultTemplate dt = (DefaultTemplate)this.GetType ().GetCustomAttributes (typeof(DefaultTemplate), true).FirstOrDefault();
- this.SetChild (Interface.Load (dt.Path, this));
- }else
- this.SetChild (template);
+ //PropertyLess binding for sizing policy in template
+ if (base.Height < 1) //send size policy to template elements
+ NotifyValueChanged ("TemplatedHeight", base.Height);
+ else //stretched in control if size is fixed
+ NotifyValueChanged ("TemplatedHeight", 0);
+ }
}
protected override void loadDefaultValues ()
@@ -76,12 +93,23 @@ namespace go
loadTemplate ();
base.loadDefaultValues ();
}
-
public override GraphicObject FindByName (string nameToFind)
{
//prevent name searching in template
return nameToFind == this.Name ? this : null;
}
+ #endregion
+
+ protected virtual void loadTemplate(GraphicObject template = null)
+ {
+ if (template == null) {
+ DefaultTemplate dt = (DefaultTemplate)this.GetType ().GetCustomAttributes (typeof(DefaultTemplate), true).FirstOrDefault();
+ this.SetChild (Interface.Load (dt.Path, this));
+ }else
+ this.SetChild (template);
+ }
+
+
#region IXmlSerializable