简体   繁体   中英

WPF, C#, binding data, AvalonDock

So I'm totally new to C#. I've done some Objective-C/iPhone programming. I'm looking through code and we have this:

DocumentPaneLeft.Items.Add(new DocumentContent
{
      Name = "sampleDockableContent",
      Title = "Samples",
      Content = new SampleView { DataContext = this.ParentForm }
});

as part of the AvalonDock we are using for the view. So now the higher ups don't like the AvalonDock and want it replaced with these other views, essentially getting rid of the layoutManger. I see that in the code above, a new SampleView is being created, and somehow getting the data for it that shows up in the view. If I change the XAML to show the view in a Grid of some sort, how do I get this data?

(Sorry for the somewhat not explicit question. I'm kind of just learning what is happening in the code).

I'm not sure what you are asking here.
Getting data in xaml is normally done with bindings. ="{Binding...}"
http://msdn.microsoft.com/en-us/library/ms752347.aspx
DataContext is where the binding can find the data.

This means you can place for example a List object on your DataContext (this.parentform) and get the data from there with bindings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM