簡體   English   中英

WPF將RelativeSource綁定到祖先問題

[英]WPF Binding RelativeSource to Ancestor Issue

我將集合的集合綁定到WPF數據網格組件(外部庫),基礎DataSource具有以下結構。 這基本上給了我一個帶有分層記錄的數據網格

class DataGridItemType
{
    public string weightType;
    public string SourceType;
    private BindingList<DataGridItem> typeCollection = new BindingList<DataGridItem>();
}


BindingList<DataGridItemType> list = new BindingList<DataGridItemType>();

list是數據網格DataSource,它執行分層綁定。 現在,我試圖結合的成分(的記錄的標題標簽一層到其數據源是typeCollection層次),以可變weightType通過使用Text="{Binding Path=weightType, Mode=TwoWay, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type btm:DataGridItemType}}}但是綁定不起作用。我丟失了什么嗎?

AncestorType應該是UI層次結構中要綁定到其DataContext(將是DataGridItemType的對象-您的自定義類)的UI元素。

這里沒有代碼段,但讀評論部分在這里

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM