Ejemplo n.º 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;
                    }
                }
            };
        }
Ejemplo n.º 2
0
        void SetTemplate()
        {
#if TODO_XAML
            var source = new swd.RelativeSource(swd.RelativeSourceMode.FindAncestor, typeof(mwc.TreeViewItem), 1);
            template1             = new mwc.Data.HierarchicalDataTemplate(typeof(ITreeItem));
            template1.VisualTree  = WpfListItemHelper.ItemTemplate(LabelEdit, source);
            template1.ItemsSource = new swd.Binding {
                Converter = new WpfTreeItemHelper.ChildrenConverter()
            };
            Control.ItemTemplate = template1;


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