public override void SetupCustomUIElements(object ui) { var nodeUI = ui as dynNodeView; //add a button to the inputGrid on the dynElement _selectButton = new dynNodeButton { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center }; _selectButton.Click += selectButton_Click; _tb = new TextBlock { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 0, 0, 0)), TextWrapping = TextWrapping.Wrap, TextTrimming = TextTrimming.WordEllipsis, MaxWidth = 200, MaxHeight = 100 }; if (SelectedElements == null || !SelectedElements.Any() || !SelectionText.Any() || !SelectButtonContent.Any()) { SelectionText = "Nothing Selected"; SelectButtonContent = "Select Instances"; } nodeUI.inputGrid.RowDefinitions.Add(new RowDefinition()); nodeUI.inputGrid.RowDefinitions.Add(new RowDefinition()); nodeUI.inputGrid.Children.Add(_tb); nodeUI.inputGrid.Children.Add(_selectButton); System.Windows.Controls.Grid.SetRow(_selectButton, 0); System.Windows.Controls.Grid.SetRow(_tb, 1); _tb.DataContext = this; _selectButton.DataContext = this; var selectTextBinding = new System.Windows.Data.Binding("SelectionText") { Mode = BindingMode.TwoWay, }; _tb.SetBinding(TextBlock.TextProperty, selectTextBinding); var buttonTextBinding = new System.Windows.Data.Binding("SelectButtonContent") { Mode = BindingMode.TwoWay, }; _selectButton.SetBinding(ContentControl.ContentProperty, buttonTextBinding); }
public override void SetupCustomUIElements(object ui) { var nodeUI = ui as dynNodeView; //add a button to the inputGrid on the dynElement var selectButton = new dynNodeButton { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center }; selectButton.Click += selectButton_Click; var tb = new TextBox { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 0, 0, 0)), BorderThickness = new Thickness(0), IsReadOnly = true, IsReadOnlyCaretVisible = false }; //tb.Text = "Nothing Selected"; if (SelectedElement == null || !SelectionText.Any() || !SelectButtonContent.Any()) { SelectionText = "Nothing Selected"; SelectButtonContent = "Select Instance"; } //NodeUI.SetRowAmount(2); nodeUI.inputGrid.RowDefinitions.Add(new RowDefinition()); nodeUI.inputGrid.RowDefinitions.Add(new RowDefinition()); nodeUI.inputGrid.Children.Add(tb); nodeUI.inputGrid.Children.Add(selectButton); System.Windows.Controls.Grid.SetRow(selectButton, 0); System.Windows.Controls.Grid.SetRow(tb, 1); tb.DataContext = this; selectButton.DataContext = this; var selectTextBinding = new System.Windows.Data.Binding("SelectionText") { Mode = BindingMode.TwoWay, }; tb.SetBinding(TextBox.TextProperty, selectTextBinding); var buttonTextBinding = new System.Windows.Data.Binding("SelectButtonContent") { Mode = BindingMode.TwoWay, }; selectButton.SetBinding(ContentControl.ContentProperty, buttonTextBinding); var buttonEnabledBinding = new System.Windows.Data.Binding("CanSelect") { Mode = BindingMode.TwoWay, }; selectButton.SetBinding(Button.IsEnabledProperty, buttonEnabledBinding); }