我有一個wpf項目由visual studio設置。我試圖創建MVP類,但我無法訪問我創建的這些類中的任何xaml屬性(例如textBox1.text或label.Content)無法理解wpf visual studio的設置
他們給我的文件是MainWindow.xaml.cs,MainWindow .xaml和其他一些文件。我可以訪問MainWindow.xaml.cs中的那些xaml屬性。但在我看來,它顯示'textBox' does not exist in the current content
。在您的XAML文件的名稱
namespace myApp
{
public interface IView
{
void clearInput();
}
public class PView: IView
{
public void clearInput()
{
textBox1.Text = ""; //error
textBox2.Text = "";
textBox3.Text = "";
}
}
我猜你會死d做額外的工作和閱讀以瞭解您需要做什麼(開箱即用,不會爲MVP,MVC,MVVM或其他任何東西設置XAML和cs文件)。不確定這是否有助於給定它的年齡:[使用模型 - 視圖 - 演示者(MVP)設計模式來啓用演示互操作性和提高可測試性](https://blogs.msdn.microsoft.com/jowardel/2008/ 09/09 /使用模型視圖演示者mvp設計模式啓用演示互操作性增加可測試性/) – crashmstr