[英]Which is the best way to access to object from another class ex.:MainPage.xaml.cs?
例如,我正在使用这种技术:
XAML
<Button x:Name="playButton" Content="Play with rabbit" With="20" Height="20"/>
MainPage.xaml.cs中
public Button _PlayButton
{
get { return playButton; }
}
PlayerControl.cs
//received instance of MainPage class to "_mainPage"
public Button Play
{
_mainPage._PlayButton.Content = "Who care about this text?";
//play logic
}
我正在寻找最佳实践。 在哪里可以深入了解该范围?
没有最佳实践。 这完全取决于您的要求。 我在各个地方使用过的方法来完成类似的任务:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.