-2

How do i access XAML control objects, such as a textbox's properties, from outside of the main partial window class?

For example, how would i change some properties of a TextBox who's named x:Name="MyTextBox" from the ServerC class? In other words, how can i, if possible, give the class ServerC permission to the XAML objects?

namespace LoginNS
{

    public partial class LoginWindow : Window
    {

        public LoginWindow()
        {
            InitializeComponent();

        }

    }

    public class ServerC
    {

    }
}
shawn a
  • 799
  • 3
  • 13
  • 21
  • [Learn Xaml, Xaml-Tutorial](http://www.c-sharpcorner.com/1/190/xaml.aspx) this is a good place to start.. – MethodMan Feb 10 '15 at 22:18

1 Answers1

0

You can inject window class on your ServerC class:

namespace LoginNS
{

    public partial class LoginWindow : Window
    {

        public LoginWindow()
        {
            InitializeComponent();

        }

    }

    public class ServerC
    {
        public ServerC(LoginWindow loginWindow){
        }
    }
}

Then manipulate that. Storing the parameter as a global variable.

jcvegan
  • 3,111
  • 9
  • 43
  • 66