I have simple Grid with Image named TestImage and I need pass that Grid instance to other class. The other class will find TestImage and it will change Source.
When I try to access to Grid from codebehind of XAML it is OK, but when I try to pass instance of Grid to other class, I can not access to TestImage there.
TestPage.xaml.cs
var otherClass = new OtherClass();
otherClass.DoSomeStuff(this.GridName);
OtherClass.cs
public void DomeSomeStuff(Grid gridInstance)
{
gridInstance.TestImage.Source = ....;
}
And I will get error message:
‘Windows.UI.Xaml.Controls.Grid’ does not contain a definition for
‘TestImage’ and no extension method ‘TestImage’ accepting a first
argument of type ‘Windows.UI.Xaml.Controls.Grid’ could be found
I understand this error, but I do not known, how to fix it.
Can you help me please?
Thank you.
Try this: