private void SetDataGrid(ShellViewModel vm) {
            QueryMessageViewModel query = vm.SelectedQuery;
            if (query == null) {
                return;
            }


            Record first = query.Parameters.FirstOrDefault();
            if (first == null) {
                this.ParametersTab.Content = null;
                this.ParametersTab.Visibility = Visibility.Collapsed;
                this.ParametersTab.IsSelected = false;
                return;
            }

            DataGrid dataGrid = new DataGrid();
            dataGrid.AutoGenerateColumns = false;
            dataGrid.IsReadOnly = true;
            dataGrid.CanUserSortColumns = false;
            dataGrid.CanUserReorderColumns = false;

            var columns = first
                .Properties
                .Select((x, i) => new {x.Name, Index = i})
                .ToArray();

            foreach (var column in columns)
            {
                var binding = new Binding(string.Format("Properties[{0}].Value", column.Index));

                dataGrid.Columns.Add(new DataGridTextColumn {Header = column.Name, Binding = binding });
            } 

            dataGrid.ItemsSource = query.Parameters;

            this.ParametersTab.Visibility = Visibility.Visible;
            this.ParametersTab.Content = dataGrid;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ShellView"/> class.
 /// </summary>
 /// <param name="viewModel">The view model.</param>
 public ShellView(ShellViewModel viewModel)
     : this()
 {
     Guard.ArgumentNotNull(viewModel, "viewModel");
     this.DataContext = viewModel;
 }
 private static void SetTextEditor(ShellViewModel vm, TextEditor textEditor) {
     textEditor.Text = vm.SelectedQuery != null ? vm.SelectedQuery.Model.Query.CommandText : "";
 }
Пример #4
0
 public ShellView(ShellViewModel viewModel)
 {
     InitializeComponent();
     DataContext = viewModel;
 }