2013-01-11 60 views
0

我想將ComboBox綁定到SpreadsheetGear工作表的命名單元格。WPF綁定到混淆對象無法找到屬性

SpreadsheetGear是一個混淆程序集,所以我第一次猜測。

<ComboBox Width="200" x:Name="comboBox" IsEditable="True" ItemsSource="{Binding Names, Mode=OneWay}"> 
    <ComboBox.ItemTemplate> 
     <DataTemplate> 
      <TextBlock Text="{Binding Name}"/> 
     </DataTemplate> 
    </ComboBox.ItemTemplate> 
</ComboBox> 

和視圖模型屬性爲

private IWorksheet worksheet; 
public IWorksheet Worksheet 
{ 
    get { return worksheet; } 
    private set { SetField(ref worksheet, value,() => Worksheet); OnPropertyChanged(() => Names); } 
} 
public IEnumerable<IName> Names 
{ 
    get { return Worksheet.Names.Cast<IName>(); } 
} 

我收到以下錯誤在我的輸出窗口

System.Windows.Data Error: 40 : BindingExpression path error: 'Name' property not found on 'object' ''ᜪ' (HashCode=1500138080)'. BindingExpression:Path=Name; DataItem='ᜪ' (HashCode=1500138080); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String') 

我試過直接返回Worksheet.Names,這不從Enumerable繼承,但DOES提供GetEnumerator()。這產生了同樣的錯誤。

任何想法?

回答

1

沒有更多的代碼,這很難說,但我會隨機猜測:IName是一個內部接口?大多數代碼混淆器只會破壞internal/private/protected類/枚舉/接口...

+0

奇怪的是,它是一個公共接口。當然內部實施。 http://www.spreadsheetgear.com/support/help/spreadsheetgear.net.7.0/#SpreadsheetGear2012~SpreadsheetGear.IName.html –

+0

@NickStrupat你可以發佈更多的視圖模型類或XAML嗎?像什麼是你的數據上下文等 – JerKimball