SpreadsheetGearワークシートの名前付きセルにComboBoxをバインドしようとしています。
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から継承しませんが、提供しますGetEnumerator()
。同じエラーが発生しました。
何か案は?