English 中文(简体)
1. 不动产
原标题:Bind a subclass to property

I have a simple question. Of course it has many answers but I cannot choose right keywords to google. How I can bind a subclass to my wpf control?

For example: It s my class.

    public class SiteFieldInfo<T>
    {
        public string Name { get; set; }
        public T Value { get; set; }
        public List<string> PositiveXPathExpressions { get; set; }
        public List<string> NegativeXPathExpressions { get; set; }
    }

    public class SiteInfo
    {
        public SiteFieldInfo<string> Author { get; set; }
        public SiteFieldInfo<DateTime> Date { get; set; }
        public SiteFieldInfo<string> Source { get; set; } 
    }

而且,我想将现场信息系统的财产价值与文本Box控制的财产相挂钩。

C# Code:

stackPanel1.DataContext = SiteInfoInstance;

xaml Code:

<StackPanel Name="stackPanel1">
<TextBlock Text="Author" />
<TextBox Text="{Binding Path=Author.Value}" />
</StackPanel>

它不工作。 什么是正确的合成物,或者什么替代物?


Sorry, 它的工作良好。 我只是 st。 如何结束问题?

最佳回答

您的<代码>SiteInfoInstance是否有数据? 我看不出你班次的结构方式或与你的中学毕业会有什么问题。

问题回答

在XAML中,称作“ToString()”的方法是否可行? 我认为,约束力将自动得到具有约束力的来源的有力代表。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签