Hello!
I have two questions regarding WPF and C#.
The first one: I am currently desingning the printing output of my application and I want to put some images into it. So I looked up some solutions online, this is what I got:
BitmapImage source = new BitmapImage(); source.BeginInit(); source.UriSource = new Uri(@"WindowsFolder/image.png"); source.EndInit();
The "WindowsFolder" is a folder in my application directory, where I put all the .xaml and their code-behind files. Obviously, Visual Studio doesn´t want to run it, I get an exception that tells me the Uri format is wrong.
What I want to do is accessing a image file that is stored in that folder. I tried putting in the full path of the file, this works. but I need the image as a resource, at least this is how I did it in Windows Forms.
Now the second question, which is bothering me since I started to use WPF and C#: I am using Expression Blend 4 and Visual Studio for developing. In Blend, I am designing the windows and in Visual Studio I do the coding.
Now I noticed that certain C#- Syntax is different in comparison to the C#- Syntax I used when working with Windows Forms. For example the refreshing of a textBox was easily done with one line in Forms, now in WPF I need a dispatcher object and threads. I suppos that has something to do with .NET?
Because of this, I often have to look up the updated C#- Syntax online. But here is the problem: If I type C# and WPF I almost exclusivly get XAML- Examples. Furthermore I have a Visual C# 2008 book at home, during the time I used WPF, I could use only very few things from the book because most of the things didn´t work with WPF. So I figured get a WPF- book. Said and done, but there are only XAML- Examples in it.
Why is the emphasis of WPF on XAML altough C#- Syntax does change with it?
regards, pat3d3r