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

  • Home
  • SEARCH
  • 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 975925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:40:04+00:00 2026-05-16T03:40:04+00:00

Hey SO, so I’ve got a custom control in Silverlight. Doesn’t really matter what

  • 0

Hey SO, so I’ve got a custom control in Silverlight. Doesn’t really matter what it is but its a big composite thing with a treeview, a slider, and some other junk.

Now in the control we have an instance variable which is called defaultTemplate. It is of type DataTemplate. Basically its the template that the TreeViewItem’s use as their header template unless the application developer calls myControl.setTemplate(DataTemplate dt);

Just by making the property public and giving it getters and setters, it shows up in intellisense when I type the following…

<myNamespace:myControl x:Name="theControl" defa

Intellisense picks up on the fact that my class has a defaultTemplate property and it lists it as an option.

What I would like:

I would like for the above functionality to continue, but add functionality for intellisense to automatically list options for the values. So I have these data templates defined in a resource dictionary which the control has access to. I want them to popup as options when I get to this part of typing:

<myNamespace:myControl x:Name="theControl" defaultTemplate="_"

The functionality I’m, looking for can be found in the TextBlock’s foreground property. As you type

foreground="" its start to list colors for you to choose from. I would be fine with defining constants as the names of my data templates and having intellisense choose from those or something like that.

How can I acheive this? Thank you!


Clarification Edit: I need to make intellisense aware of a list of constants which are acceptable inputs for the xaml property. So my defaultTemplate property can just be a string. I’ll deal with what that string means in my code behind. But I need intellisense to know what strings are ok to enter for that property in the XAML. The foreground color once you type the quote pops up a list in intellisense that is like “Azure, Beige… LemonChiffon… etc.” How do I provide intellisense with that list?
Thanks!


Final Edit: Thanks to siege898 I can now choice my values for defaultTemplate from a list that intellisense provides me. However, I would also like to be able to give the application developer (who uses my control) an option to define their own data template and specify the name of it.

So for example, Bob is using my control in his application. None of the templates I provide are suitable for him. So Bob creates in a resource dictionary a data template for his application called bobTemplate. I would like for Bob to be able to enter in the defaultTemplate field in xaml defaultTemplate="bobTemplate" and not have that throw an error. I believe the problem I’m having now is because the field is expecting a value in my enum. Does anyone know how I can set this up to both give me the dropdown list generated from the enum, but still accept custom strings? I was thinking a type converter, but I’m not sure how to use it for what I want…

  • 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-05-16T03:40:05+00:00Added an answer on May 16, 2026 at 3:40 am

    I think what you’re working for is an enumerated property.
    So here’s what I suggest:

    public enum Templates
    {
        Template1, Template2, ...
    }
    
    public Templates defaultTemplates
    {
       get;
       set;
    }
    

    However, because its an enumerated property, when the user passes a value (for instance Template1), the app will see that as a integer (0 = Template1, 1 = Template2…)

    So I also suggest keeping some sort of dictionary, or having a lookup function that maps each integer to the template you want. (Or even a type converter as mentioned above)

    I’m not 100% sure why this adds to intellisense, but in my experience it always has, even in XAML. I think that VS sees that defaultTemplates must be set to one of the values in Templates so it then populates the list.

    Hope this is what you’re looking for.

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

Sidebar

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.