Skip to main content

Microsoft Silverlight

Answered Question Making Custom Controls Internal to a Custom Control AssemblyRSS Feed

(0)

michael_weed
michael_...

Member

Member

29 points

38 Posts

Making Custom Controls Internal to a Custom Control Assembly

Is it possible to make certain custom controls in an assembly internal to that assembly -- where the publicly-scoped controls could use the internally-scoped controls but external users of the assembly could not?

Regards,

Mike Weed

Bigsby
Bigsby

Member

Member

262 points

81 Posts

Re: Making Custom Controls Internal to a Custom Control Assembly

 Yes.

I use that a lot with custom Panels.

michael_weed
michael_...

Member

Member

29 points

38 Posts

Re: Making Custom Controls Internal to a Custom Control Assembly

Hi Bigsby,

Exactly.  But how did you do it?  When I mark the desired control classes "internal" I get design-time errors when I go to use one of the publicly-scoped controls in a project.  Besides marking the control classes as internal, is there something else I need to do to the style markup in generic.xaml to "hide" these internal controls?

Regards,

Mike Weed

Bigsby
Bigsby

Member

Member

262 points

81 Posts

Re: Making Custom Controls Internal to a Custom Control Assembly

I'll make a working sample tonight and provide it so you can check it out.

Regarding the generic.xaml question, I'll have to check it out but there shouldn't be nothing else to hide once the Controls are modified as internal. One thing I really don't like that closed process of accessing a file called specifically generic.xaml, specifically in the a folder called Themes and adding resources that you can´t access... too blury for my taste.

 Never the less... later on I'll provide the sample.

michael_weed
michael_...

Member

Member

29 points

38 Posts

Re: Making Custom Controls Internal to a Custom Control Assembly

Great!

I agree with you about the requirement of using a resource dictionary with a required name of generic.xaml.  Perhaps this will evolve over time.

Thanks again for your help!

Regards,

Mike Weed

michael_weed
michael_...

Member

Member

29 points

38 Posts

Re: Making Custom Controls Internal to a Custom Control Assembly

Hi Bigsby,

Do you have a working example of this you can provide?  As I said before, I've tried simply marking the controls I intend to hide as "internal" and this has not worked.  I get a design-time error as soon as I try to use any of the publiclly-scoped controls that depend on one of the internal controls.  The error only goes away when I mark all of the controls as "public" again.

Regards,

Mike Weed

Bigsby
Bigsby

Member

Member

262 points

81 Posts

Answered Question

Re: Making Custom Controls Internal to a Custom Control Assembly

 There you go.

You can get the working sample here

Hope it helps.

What happens is that generic.xaml is just a kind of patch to workaround the fact that ResourceDictionary is not WPF like implemented yet. The consequence of this is that generic.xaml is parsed "outside" the assembly thus not knowing the internal types. So, to use the internal controls and style them, you'll have to workaround in a manner like the one I propose in the sample.

 The reason I didn't run into this kind of trouble in my Panel implementation is I was using the panels precisely to make the parsing/constructing of the UI objects faster not using any XAML and setting my own optimized measure and arranging methods. This was, naturally, all done in the code behind.

 If you look at the way I'm getting the Style for the PrivateButton type, you'll see the way I'm setting my styles, now-a-days. I use a private static (thus only instanciated in the first object) field and set it in the constructor. One of the advantage of this is that you don't 3 miles of generic.xaml with all the styles in it which is very little workable.

Well. I think this is enough for you to get the picture.

 

Anything else, just whistle.

Bruno.

michael_weed
michael_...

Member

Member

29 points

38 Posts

Re: Making Custom Controls Internal to a Custom Control Assembly

Thanks Bruno.  I'll start digging into this right away!

Regards,

Mike Weed
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities