SLConnDomainContext dbContext = new SLConnDomainContext();
private LoadOperation<Employee> loadOp;
ObservableCollection<Employee> data = new ObservableCollection<Employee>();
loadOp = this.dbContext.Load(this.dbContext.GetEmployeesQuery());
loadOp.Completed += new EventHandler(loadOp_Completed);
void loadOp_Completed(object sender, EventArgs e)
foreach (Employee emp in loadOp.Entities)
dataForm.ItemsSource = data;
I would like to move to a MVVM approach and have created a viewmodel to retrieve the data and pass it into a view by creating an instance of my viewmodel and setting the datacontext property of my listbox. The viewmodel works fine when I am just creating some mock data and populating a list. However, due to the asynchronous nature of using a loadoperation with silverlight, the above code doesn't work with the MVVM approach for me. The data is retrieved but it appears that it is after my view has already loaded so it never appears. Below is my code:
Why do you have _employees and _myEmployees? The main issue is that _myEmployees = employees doesn't trigger a change notification, so you'd have to call OnPropertyChanged("myEmployees") after the assignment. That is the correct method, but then employees should be a local object, not a class member.
I could not find no example on how to write a wpf control that wraps c++ win32 window. If some one could provide me with a link to a newbie-like tutorial/documentation (sample code would be good too) on how to create c# libraries that wrap c++ code I would be very thankful.
Thanks in advance.
Thx for the link. I found that one my self and I tried to modify the sample code to my needs but i failed.
I'll try to explain more what I'm trying to do.
So I have 3rd party OpenGL application written in C++ that is capable to show its output on another process window by passing a HWND pointer of that window (re-parenting).
If I create basic C++ Win32 aplication and pass its window HWND to that 3rd application I see output of that application in my application window.
Since I don't know C++ programming that well and I'm a little better at C#, I would like to create a WPF control that wraps C++ window in a dll that I can use in my WPF project.
Now the problem is that I can't figure out how to override WM_PAINT function so that WPF would be able to render that control correctly.
Because now I get that control instantiated and I get the HWND of that control (which is different of the WPF window hosting it) but when I pass it to that 3rd party application nothing happens.
My guess is that WM_PAINT is being called correctly but WPF window is not rendering that control because it knows nothing of WM_PAINT ?!
Now, the MSDN resource is a bit difficult for me to figure out how to solve my problem. Mostly because I need some easy reading on how to write managed c++/clr code.
Any suggestion on some websites or books that explain this subject (on elementary school level ) ?
So I have PInvoked BeginPaint() and EndPaint() funcrions also.
And I'm able to draw inside my win32 window from there.
But my 3rd party application still can't and I don't know what else do I need to override to make it work.
At this point there is no difference between win32 window hosted in WPF application and win32 window created by c++ win32 application or is there ?!
Maybe type of class inside CreateWindowEx function ("static") should be something different, or some of window parameters should be changed.
My guess is that WPF is preventing win32 window from communicating with 3rd party process. Response from 3rd party app is: "visual not possible"
Here is link to my project if anyone interested to look what I did so far.
Don't know if there is a way to simulate my situation by trying to redirect (reparent) some other application (that uses win32) window output to my app. I'm not in position to share that 3rd party application that I'm using.
The 3rd party vendor don't consider this to be a valid customer API request as this is something they use internally (they have couple of apps that can do this and they have some interop wpf dll's for this but it is not exposed for others)
Last Visit: 31-Dec-99 19:00 Last Update: 25-Dec-14 14:09