Home > other >  How WPF in c #. CS file to use. The controls in the xaml
How WPF in c #. CS file to use. The controls in the xaml

Time:10-07


 
This is. Xaml defined controls:


 
This is. The code in the cs:
Public Menu ()
{
InitializeComponent();

Notification. Text="... FHHH ";//here is not an error, but in the outside call Notification will be an error?
//use the Notification outside. The text would be an error,
}

CodePudding user response:

Just learning WPF, hurry hurry hurry hurry hurry hurry, stuck in this for two days

CodePudding user response:

Outside, it is not the same class, of course, don't know it

CodePudding user response:

What you said is outside?

CodePudding user response:

Outside in the function of that what should do to use this control? I want to use textbox display some text in these functions,

CodePudding user response:

Simple point, you put the method to the inside to outside, complex point need to entrust

CodePudding user response:

x: Name="txtXXX" HorizontalAlign
The background to use txtXXX directly

CodePudding user response:

The Name="Notification" instead of x: Name="Notification"
So you can call a change in the background

CodePudding user response:

WPF xmal and corresponding cs is one kind of the same class can access its members, of course, what you said in the outside should be in the other class is not in a class of error accessing how could that be? This is one of the basic knowledge

CodePudding user response:

1, first of all to control defines a Name

CodePudding user response:

1, first of all to control defines a Name

2, directly in the associated xaml. Cs file using the

Notification. Text="Hello";

3, FindName () method

CodePudding user response:

Use outside Notification said this is where the best outside see

First, you use the control name in the constructor. There is no question of text='string'

But I suggest that you still have the control in the XAML name changed to x: Name

Then you can be in any class method . The text="string"

Feeling and new to WPF it doesn't matter if is new to programming is new to programming so that we can help you to analyze the depth of the better to guide you

CodePudding user response:

Defines a delegate, the delegate using the control method, call the delegate method outside,

CodePudding user response:

Use in other classes, to define the instance of the class,
  • Related