locked
codebehind a usercontrol makes elements private... RRS feed

  • Question

  • Is this new behavior in the CP?

    Will this remain for the release?

    In Silverlight all elements auto-generated by the "InitializeComponent" function are Public...in the Win8 CP Metro all elements are private. This will lead to lots of code re-write in order to reuse Silverlight code on Metro. I just want to make sure that this is a new policy and not just a fluke in the CP.

    Thanks,


    Chris Muench, MVP

    Wednesday, March 7, 2012 9:25 PM

All replies

  • And is it possible that Metros Styles do no longer allow dashes in the Key Name?

    i.e: <FontFamily x:Key="C-LabsFont">Tahoma</FontFamily>

    In a resource directory


    Chris Muench, MVP

    Wednesday, March 7, 2012 9:52 PM
  • Hi Chris,

    sorry for the late reply, so to compare I generated a VS 2010 Silverlight Application:

    internal System.Windows.Controls.Grid LayoutRoot; internal System.Windows.Controls.Button button1; internal System.Windows.Controls.CheckBox checkBox1; private bool _contentLoaded; ...

    public void InitializeComponent() {     if (_contentLoaded) {         return;     }     _contentLoaded = true;     System.Windows.Application.LoadComponent(thisnew System.Uri("/SilverlightApplica     this.LayoutRoot = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot")));     this.button1 = ((System.Windows.Controls.Button)(this.FindName("button1")));     this.checkBox1 = ((System.Windows.Controls.CheckBox)(this.FindName("checkBox1")));

    In VS 11 Beta, it was the same as above except a name wasn't autogenerated in the XAML.

    Could you post a quick snippet of the change you are seeing?

    much appreciated,

    mike

    System.Windows.Controls.Grid LayoutRoot;

    internal

    System.Windows.Controls.Button button1;

    private

    bool _contentLoaded;

    ///

    <summary>

    ///

    InitializeComponent

    ///

    </summary>

    [System.Diagnostics.

    DebuggerNonUserCodeAttribute()]

    public

    void InitializeComponent() {

    if (_contentLoaded) {

    return;

    }

    _contentLoaded =

    true;

    System.Windows.

    Application.LoadComponent(this, new System.Uri("/Silverlight

    this.LayoutRoot = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot

    this.button1 = ((System.Windows.Controls.Button)(this.FindName("button1")))

    Friday, March 9, 2012 9:44 PM
    Moderator
  • private System.Windows.Controls.Grid LayoutRoot;

    private System.Windows.Controls.Button button1;

    private System.Windows.Controls.CheckBox checkBox1

    Declarations are now "private" no longer "internal"


    Chris Muench, MVP

    Friday, March 9, 2012 9:45 PM