ZeroTouch Node with WPF

I put everything in one class and it didn’t change the import of the whole system category.

I did manage to get the select method to stop showing up by marking it abstract.

Here’s a peak at my code, (Be gentle I am a noob at this for sure. :wink:)

###My Selection Class
using Autodesk.DesignScript.Runtime;
using Dynamo.Graph.Nodes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace Beaker
{
    public abstract class Selection
    {
        /// <summary>
        /// This node will take an input list and allow you to choose items in it.
        /// Compatible with Dynamo Player.
        /// </summary>
        /// <param name="list">Input list</param>
        /// <returns name="selectedItems">The user selected items.</returns>
        /// <search>
        /// Pick, UI, Filter
        /// </search>
        public static List<Object> PickItemsFromList (List<Object> list)
        {
            List<Object> listReturn = new List<object>();
            PickFromList window = new PickFromList();

            //selectList
            window.listBox.ItemsSource = list;


            var res = window.ShowDialog();  
            if (!res.HasValue && res.Value)
                window.Close();

            var data = window.listBox.SelectedItems;
            foreach (object element in data)
            {
                listReturn.Add(element);
            }
            return listReturn;
        }
    }
}

###And the class for my XAML

using Autodesk.DesignScript.Runtime;
using System.Windows;
using System.Windows.Controls;

namespace Beaker
{
    [IsVisibleInDynamoLibrary(false)]
    /// <summary>
    /// Interaction logic for PickFromList.xaml
    /// </summary>
    public partial class PickFromList 
    {
        internal PickFromList()
        {
            InitializeComponent();
        }

        private void accept_button_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = true;
        }
        private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

        }

    }
}
2 Likes