示例#1
0
        /// <summary>
        /// Initializes a new instance of <see cref="InnerListColumn"/> class with the specified data description and visibility.
        /// </summary>
        /// <param name="dataDescription">The description of the data this column is bound to.</param>
        /// <param name="isVisible">Whether the column is initially visible.</param>
        /// <param name="createDefaultBinding">Whether the column should create a default binding using the specified data's property.</param>
        public InnerListColumn(UIPropertyGroupDescription dataDescription, bool isVisible, bool createDefaultBinding)
        {
            if (dataDescription == null)
            {
                throw new ArgumentNullException("dataDescription");
            }

            GridViewColumnHeader header = new GridViewColumnHeader();
            header.Content = dataDescription.DisplayContent;
            header.DataContext = this;

            Binding automationNameBinding = new Binding("DataDescription.DisplayName");
            automationNameBinding.Source = this;
            header.SetBinding(AutomationProperties.NameProperty, automationNameBinding);

            this.Visible = isVisible;
            this.Header = header;
            this.DataDescription = dataDescription;

            if (createDefaultBinding)
            {
                var defaultBinding = new Binding(GraphicalHostReflectionWrapper.EscapeBinding(dataDescription.PropertyName));
                defaultBinding.StringFormat = GetDefaultStringFormat(dataDescription.DataType);
                defaultBinding.ConverterCulture = CultureInfo.CurrentCulture;

                this.DisplayMemberBinding = defaultBinding;
            }
        }