简体   繁体   English

WPF、C#、绑定数据、AvalonDock

[英]WPF, C#, binding data, AvalonDock

So I'm totally new to C#.所以我对 C# 完全陌生。 I've done some Objective-C/iPhone programming.我已经完成了一些 Objective-C/iPhone 编程。 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.作为我们用于视图的 AvalonDock 的一部分。 So now the higher ups don't like the AvalonDock and want it replaced with these other views, essentially getting rid of the layoutManger.所以现在高层不喜欢 AvalonDock 并希望将其替换为这些其他视图,基本上摆脱了 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.我看到在上面的代码中,正在创建一个新的 SampleView,并以某种方式获取显示在视图中的数据。 If I change the XAML to show the view in a Grid of some sort, how do I get this data?如果我更改 XAML 以在某种网格中显示视图,我如何获取这些数据?

(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.在 xaml 中获取数据通常是通过绑定完成的。 ="{Binding...}" ="{绑定...}"
http://msdn.microsoft.com/en-us/library/ms752347.aspx http://msdn.microsoft.com/en-us/library/ms752347.aspx
DataContext is where the binding can find the data. DataContext 是绑定可以找到数据的地方。

This means you can place for example a List object on your DataContext (this.parentform) and get the data from there with bindings.这意味着您可以在 DataContext (this.parentform) 上放置例如 List object 并通过绑定从那里获取数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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