Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9044335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:57:36+00:00 2026-06-16T10:57:36+00:00

I have a custom control which has a columns collection stored as internal property

  • 0

I have a custom control which has a columns collection stored as internal property in markup.
The markup looks something like this:

<CustomGrid:CompositeGrid ID="myGrid1" runat="server" ReturnToFirstPageOnSort="true"
     PagerArrowsDisapearWhenNextPrevDisabled="true" AlternatingRowStyling="true">
        <Columns>
            <CustomGrid:DataColumn DataSourceID="TestDate" FormatString="dd.MM.yyyy"
                 Sortable="true" Visible="true" />
            <CustomGrid:DataColumn DataSourceID="TestType" />
            <CustomGrid:DataColumn DataSourceID="Referrer" />
            <CustomGrid:ImageColumn DataSourceID="StatusIcon"
                TextDataSourceID="Status" IncludeText="true" ImageAlt="IconAlt"
                ImageOnThe="Right" />
            <CustomGrid:LinkColumn>
                <Links>
                    <CustomGrid:LinkButtonItem CommandArgument="PDFId" CommandName="GetPDF" />
                    <CustomGrid:OpenDescriptionItem />
                </Links>
            </CustomGrid:LinkColumn>
            <CustomGrid:UserDefinedColumn ImplementingColumnType="MyColumn" HeaderText="User Defined Column" />
            <CustomGrid:DescriptionBlock DataSourceID="TestDate" />
        </Columns>
    </CustomGrid:CompositeGrid>

There are several types of column, and one of the types is a description column. I want to “force” the developer using the control to always put the description column last (if it is present at all). Can I add custom markup validation rules? Can I mark the markup with a red squigly line if the description column is placed anywhere but in that last position? Can I fail web site validation if this rule is violated?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T10:57:37+00:00Added an answer on June 16, 2026 at 10:57 am

    I think you should just create a separate property for DescriptionColumn and make it a different base class if you want to make it special. Or, you could just always sort the columns that way regardless of how the user of the control defines the columns.

    Update

    Well, I decided to give your idea a go and create a custom exception. I think all you need to do is handle the case in your custom control and throw your own exception. No custom XML validation rules, just a normal .NET exception.

    Custom XAML Exception

    Here’s the relevant portion of the code.

    public class DataGrid
    {
        ObservableCollection<BaseColumn> columns = new ObservableCollection<BaseColumn>();
    
        public DataGrid()
        {
            columns.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(subClasses_CollectionChanged);
        }
    
        void subClasses_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            int count = columns.Count(x => x is DescriptionColumn);
    
            if (count > 1)
            {
                throw new CustomDataGridException("You can only have one description column");
            }
            if (count == 1)
            {
                if (!(columns[columns.Count - 1] is DescriptionColumn))
                    throw new CustomDataGridException("Description column must be last");
            }
        }
    
        public ObservableCollection<BaseColumn> Columns
        {
            get
            {
                return columns;
            }
    
            set
            {
    
                if(columns != null)
                    columns.CollectionChanged -= subClasses_CollectionChanged;
    
                columns = value;
    
                if (columns != null)
                    columns.CollectionChanged += subClasses_CollectionChanged;
            }
        }
    }
    

    Just make sure to recompile, close and re-open the designer window or it may not update.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom control which has a property of type Collection<System.Drawing.Point> . When
I have written a custom server control which (pseudo-code) looks like public class MyCustomCtrl
I have an ASP.NET GridView which has columns that look like this: | Foo
I have a custom control which contains a Repeater control. The Repeater has an
I have a control which has a default value for a property. When the
I have created a custom control which displays a number pad. The control has
We have a custom canvas which has specialized nodes that behave a lot like
I have a custom control in winform, which is a search textbox. It has
I have a custom control which has a RadioButtonList control in it. On selecting
I have a custom control which includes a property of the following definition: [PersistenceMode(PersistenceMode.InnerProperty)]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.