Beispiel #1
0
        public ListBoxHandler()
        {
            Control = new swc.ListBox();
            Control.HorizontalAlignment = sw.HorizontalAlignment.Stretch;
            //Control.DisplayMemberPath = "Text";
            var template = new sw.DataTemplate(typeof(IListItem));

            template.VisualTree       = WpfListItemHelper.ItemTemplate(false);
            Control.ItemTemplate      = template;
            Control.SelectionChanged += delegate
            {
                Widget.OnSelectedIndexChanged(EventArgs.Empty);
            };
            Control.MouseDoubleClick += delegate
            {
                if (SelectedIndex >= 0)
                {
                    Widget.OnActivated(EventArgs.Empty);
                }
            };
            Control.KeyDown += (sender, e) =>
            {
                if (e.Key == sw.Input.Key.Return)
                {
                    if (SelectedIndex >= 0)
                    {
                        Widget.OnActivated(EventArgs.Empty);
                        e.Handled = true;
                    }
                }
            };
        }
Beispiel #2
0
        public TreeViewHandler()
        {
            Control = new EtoTreeView();
            var template = new sw.HierarchicalDataTemplate(typeof(ITreeItem));

            template.VisualTree  = WpfListItemHelper.ItemTemplate();
            template.ItemsSource = new swd.Binding {
                Converter = new WpfTreeItemHelper.ChildrenConverter()
            };
            Control.ItemTemplate = template;

            var style = new sw.Style(typeof(swc.TreeViewItem));

            //style.Setters.Add (new sw.Setter (swc.TreeViewItem.IsExpandedProperty, new swd.Binding { Converter = new WpfTreeItemHelper.IsExpandedConverter (), Mode = swd.BindingMode.OneWay }));
            style.Setters.Add(new sw.Setter(swc.TreeViewItem.IsExpandedProperty, new swd.Binding {
                Path = expandedProperty, Mode = swd.BindingMode.TwoWay
            }));
            Control.ItemContainerStyle = style;

            ITreeItem oldSelectedItem = null;

            Control.CurrentItemChanged += (sender, e) => {
                Control.Dispatcher.BeginInvoke(new Action(() => {
                    var newSelected = this.SelectedItem;
                    if (oldSelectedItem != newSelected)
                    {
                        Widget.OnSelectionChanged(EventArgs.Empty);
                        oldSelectedItem = newSelected;
                        this.RefreshData();
                    }
                }));
            };
        }
Beispiel #3
0
        void SetTemplate()
        {
            var source = new swd.RelativeSource(swd.RelativeSourceMode.FindAncestor, typeof(swc.TreeViewItem), 1);

            template1             = new sw.HierarchicalDataTemplate(typeof(ITreeItem));
            template1.VisualTree  = WpfListItemHelper.ItemTemplate(LabelEdit, source);
            template1.ItemsSource = new swd.Binding {
                Converter = new WpfTreeItemHelper.ChildrenConverter()
            };
            Control.ItemTemplate = template1;

            template2             = new sw.HierarchicalDataTemplate(typeof(ITreeItem));
            template2.VisualTree  = WpfListItemHelper.ItemTemplate(LabelEdit, source);
            template2.ItemsSource = new swd.Binding {
                Converter = new WpfTreeItemHelper.ChildrenConverter()
            };
        }