aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2015-08-21 16:13:12 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2015-08-21 16:13:12 +0200
commit4464d8c4d183a963a0c39f5eea393529ebbbc013 (patch)
tree230b8cf4bf05c13054c1bc25406defbffb4c76e6 /src/GraphicObjects
parent4c45c1aba33ea287650bef43543af559b8804fae (diff)
Item template property for listbox, added ItemTemplate for testTypeViewer
Diffstat (limited to 'src/GraphicObjects')
-rw-r--r--src/GraphicObjects/ListBox.cs12
-rw-r--r--src/GraphicObjects/TemplatedControl.cs14
2 files changed, 20 insertions, 6 deletions
diff --git a/src/GraphicObjects/ListBox.cs b/src/GraphicObjects/ListBox.cs
index a66fe7d4..117dd626 100644
--- a/src/GraphicObjects/ListBox.cs
+++ b/src/GraphicObjects/ListBox.cs
@@ -26,6 +26,7 @@ using System.ComponentModel;
namespace go
{
[DefaultTemplate("#go.Templates.Listbox.goml")]
+ //[DefaultTemplate("#go.Templates.ItemTemplate.goml")]
public class ListBox : TemplatedControl
{
Group _list;
@@ -44,13 +45,19 @@ namespace go
ICollection data;
int _selectedIndex;
+ string _itemTemplate;
+ [XmlAttributeAttribute][DefaultValue("#go.Templates.ItemTemplate.goml")]
+ public string ItemTemplate {
+ get { return _itemTemplate; }
+ set { _itemTemplate = value; }
+ }
public int SelectedIndex{
get { return _selectedIndex; }
set { _selectedIndex = value; }
}
- [XmlAttributeAttribute()][DefaultValue(null)]
+ [XmlAttributeAttribute][DefaultValue(null)]
public ICollection Data {
get {
return data;
@@ -62,7 +69,8 @@ namespace go
if (data == null)
return;
foreach (var item in data) {
- GraphicObject g = Interface.Load ("#go.Templates.ItemTemplate.goml", item);
+ GraphicObject g = Interface.Load (ItemTemplate, item);
+ //GraphicObject g = Interface.Load ("#go.Templates.Listbox.goml", item);
// g.Tag = item;
// g.MouseClick += (object sender, OpenTK.Input.MouseButtonEventArgs e) => {
//
diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs
index 7c50a2ea..d8af0bdf 100644
--- a/src/GraphicObjects/TemplatedControl.cs
+++ b/src/GraphicObjects/TemplatedControl.cs
@@ -37,6 +37,15 @@ namespace go
Path = path;
}
}
+ [AttributeUsage(AttributeTargets.Class)]
+ public class DefaultItemTemplate : Attribute
+ {
+ public string Path = "";
+ public DefaultItemTemplate(string path)
+ {
+ Path = path;
+ }
+ }
public abstract class TemplatedControl : PrivateContainer, IXmlSerializable
{
@@ -77,10 +86,7 @@ namespace go
#region IXmlSerializable
- public override System.Xml.Schema.XmlSchema GetSchema()
- {
- return null;
- }
+ public override System.Xml.Schema.XmlSchema GetSchema(){ return null; }
public override void ReadXml(System.Xml.XmlReader reader)
{
//Template could be either an attribute containing path or expressed inlined