How to draw a pixel in WPF

I'm sorry that I asked such a simple question, but it makes me wonder.

I write in C #, WPF, and all I need to do is draw a pixel at the x, y location of a specific RGB value.

What I'm starting up is the namespaces used by the dll for links, etc. Any code I find causes a ton of compilation errors.

So, just something short and sweet that will put an RGB value point, regardless of the specific x, y coordinate in the window, will really make my day.

Please include all the sample code that will compile, link, and run in Visual Studio 2010. As I said, all the code fragments that I found throw a ton of errors (everything from the ambiguous "Brush" to ... well, you name this is). And, yes, I'm just starting to write in WPF.

Thanks in advance!


This is for Surfbutler:

Here is an example (right here: http://msdn.microsoft.com/en-us/library/ms747393.aspx ):

// Add a Line Element myLine = new Line(); myLine.Stroke = System.Windows.Media.Brushes.LightSteelBlue; myLine.X1 = 1; myLine.X2 = 50; myLine.Y1 = 1; myLine.Y2 = 50; myLine.HorizontalAlignment = HorizontalAlignment.Left; myLine.VerticalAlignment = VerticalAlignment.Center; myLine.StrokeThickness = 2; myGrid.Children.Add(myLine); 

And it throws errors without knowing what Line () ... or myGrid is (will it be declared in XAML?

+4
source share
1 answer

I found the missing assembly of WindowsBase.dll! He was buried, and I had to look for him!

Now I have only one error left ... myGrid does not exist in the current context.

Is this declared in the XAML window? I suspect this is so. But this is in another project. How can I refer to MainWindow for two projects that exist in one solution?

0
source

Source: https://habr.com/ru/post/1438114/


All Articles