I working on add-on which integrates with ChartTrader.
I have two questions:
1. Is there is a way to identify if another add-on already hosted in char trader and how to correctly place my add-on in Grid and to not broke another integration.
2. I faced an issue while working with ListView item template which is content for an expander. I have simple code:
private ListView ListView; protected override void OnWindowCreated(Window window) { // chart trader routine. // Create the Grid var userControl = new UserControl(); Grid.SetRow(userControl, 8); userControl.Content = LoadPositionPlacingXML(); _mainGrid.Children.Add(userControl); } private DependencyObject LoadPositionPlacingXML() { Expander = LogicalTreeHelper.FindLogicalNode(xaml, "Expander") as Expander; CreateListView(); // _listViewSource is ObservableCollection _listViewSource.Add(new NewClass() { Element = "100" }); _listViewSource.Add(new NewClass() { Element = "100" }); _listViewSource.Add(new NewClass() { Element = "100" }); _listViewSource.Add(new NewClass() { Element = "100" }); _listViewSource.Add(new NewClass() { Element = "100" }); ListView.ItemsSource = _listViewSource; Expander.Content = ListView; } private void CreateListView() { // Create the ListView ListView = new System.Windows.Controls.ListView(); // Create the item template DataTemplate itemTemplate = new DataTemplate(); // Create the Grid FrameworkElementFactory gridFactory = new FrameworkElementFactory(typeof(Grid)); FrameworkElementFactory col1 = new FrameworkElementFactory(typeof(ColumnDefinition)); FrameworkElementFactory col2 = new FrameworkElementFactory(typeof(ColumnDefinition)); FrameworkElementFactory col3 = new FrameworkElementFactory(typeof(ColumnDefinition)); FrameworkElementFactory row = new FrameworkElementFactory(typeof(RowDefinition)); FrameworkElementFactory row1 = new FrameworkElementFactory(typeof(RowDefinition)); col1.SetValue(ColumnDefinition.WidthProperty, new GridLength(4, GridUnitType.Star)); col2.SetValue(ColumnDefinition.WidthProperty, new GridLength(1, GridUnitType.Star)); col3.SetValue(ColumnDefinition.WidthProperty, new GridLength(1, GridUnitType.Star)); row.SetValue(RowDefinition.HeightProperty, new GridLength(1, GridUnitType.Auto)); row1.SetValue(RowDefinition.HeightProperty, new GridLength(1, GridUnitType.Star)); gridFactory.AppendChild(col1); gridFactory.AppendChild(col2); gridFactory.AppendChild(col3); // Create the TextBlock FrameworkElementFactory textBlockFactory = new FrameworkElementFactory(typeof(TextBlock)); textBlockFactory.SetValue(TextBlock.TextProperty, "Some text %"); textBlockFactory.SetValue(Grid.RowProperty, 0); textBlockFactory.SetValue(Grid.ColumnSpanProperty, 3); textBlockFactory.SetValue(TextBlock.FontSizeProperty, 8.0); textBlockFactory.SetValue(TextBlock.ForegroundProperty, Brushes.LightGray); // Create the TextBox FrameworkElementFactory textBoxFactory = new FrameworkElementFactory(typeof(NumericTextBox)); textBoxFactory.SetValue(Grid.RowProperty, 1); textBoxFactory.SetValue(Grid.ColumnProperty, 0); Binding positionBinding = new Binding("Element"); textBoxFactory.SetBinding(NumericTextBox.TextProperty, positionBinding); // Create the Button "-" FrameworkElementFactory minusButtonFactory = new FrameworkElementFactory(typeof(System.Windows.Controls.Button)); minusButtonFactory.SetValue(Grid.RowProperty, 1); minusButtonFactory.SetValue(Grid.ColumnProperty, 1); minusButtonFactory.SetValue(System.Windows.Controls.Button.ContentProperty, "-"); // Create the Button "+" FrameworkElementFactory plusButtonFactory = new FrameworkElementFactory(typeof(System.Windows.Controls.Button)); plusButtonFactory.SetValue(Grid.RowProperty, 1); plusButtonFactory.SetValue(Grid.ColumnProperty, 2); plusButtonFactory.SetValue(System.Windows.Controls.Button.ContentProperty, "+"); // Add the child elements to the Grid gridFactory.AppendChild(textBlockFactory); gridFactory.AppendChild(textBoxFactory); gridFactory.AppendChild(minusButtonFactory); gridFactory.AppendChild(plusButtonFactory); // Set the Grid as the visual tree of the DataTemplate itemTemplate.VisualTree = gridFactory; // Assign the item template to the ListView ListView.ItemTemplate = itemTemplate; } public class NewClass { public string Element {get;set;} }
Chart Trader result:
Is there is some specifics that I don't know? How can I specify list view item template and correctly bind properties for list item?
Thanks
Comment