Skip to main content

Microsoft Silverlight

Answered Question Scope definition changes when altering XAMLRSS Feed

(0)

ThatRickGuy
ThatRickGuy

Member

Member

18 points

75 Posts

Scope definition changes when altering XAML

Hi guys,

 Ran into a bit of an oddity. I have a canvas on a xaml control that I have manually changed its scope to 'Public'. I can load the file in the VS2008 xaml viewer just fine, and the application runs with out a problem. But any time I modify the XAML in either the XAML/Design interface in VS2008, or in Blend, the Page.g.vb file reverts the scope of my canvas from 'Public' back to 'Friend'.

 I need that canvas to be public so that I can access it from a class library that holds all of my communication and error handling frame work. 

-Rick

 

Keith.Mahoney
Keith.Ma...

Participant

Participant

872 points

131 Posts

Microsoft
Answered Question

Re: Scope definition changes when altering XAML

Hi ThatRickGuy,
The g.cs/g.vb files are automatically generated and as such should not be modified manually as any changes made to these files will be lost next time the file is re-generated.

If you want to expose one of the child elements of your UserControl, you can create a public property or field, and set it to the correct value in the UserControls constructor.

 
e.g.

public class UserControl1 : UserControl
{
    public UserControl1()
    {
        InitializeComponent();
        myCanvas = _canvas1;
    }
    
    public Canvas MyCanvas;
}


or, using a read only property:

public class UserControl1 : UserControl
{
    public UserControl1()
    {
        InitializeComponent();
    }
    
    public Canvas MyCanvas
    {
        get
        {
            return canvas1;
        }
    }
}
 

Keith Mahoney
Silverlight SDET
Microsoft
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities