Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

got a error : calling a wpf from a console apps and how to pass a value to wpf

$
0
0

Hi

Am new to wpf and C#, so any comments are big welcome.

I am trying build a wpf form, and two issues for now,

The wpf form need a input from parents like

MainWindow("This is inout string")

so my 1st question, I don’t know the easy way to pass this to the form.

public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            InitializeTextBox();
        }
        public MainWindow(string RunType) 
        {
            InitializeComponent();
            versionDescribtionTextBox.Text = RunType;
        }
    }

2nd I've tried this bit code, and hopefully works, but once I tried run the wpf from a console apps, it has following error : The calling thread must be STA, because many UI components require this.

static void Main()

        {

            System.Windows.Application app = new System.Windows.Application();

            app.Run(new WpfApplication1.MainWindow("This is inout string"));

        }


Thanks a lot

Viewing all articles
Browse latest Browse all 18858

Trending Articles