私は以下のような複合型を持っています
public class EmployeessList
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LatName { get; set; }
}
上記のcomplextypeのリストをデータグリッドにバインドするので、
<sdk:DataGridTemplateColumn Header="Value" Width="150*" >
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel VerticalAlignment="Center">
<TextBox x:Name="{Binding Id}" Text="{Binding FirstName,Mode=TwoWay}" />
</StackPanel>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
上記のように、複数のプロパティをテキストボックスの複数の属性にバインドしたい
このコードを実行すると、以下のようにエラー xaml parse exception が発生します。
---------------------------
Message from webpage
---------------------------
Unhandled Error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException: System.Windows.Markup.XamlParseException: The name already exists in the tree: . [Line: 0 Position: 0] ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at System.Windows.ResourceManagerWrapper.GetResourceForUri(Uri xamlUri, Type componentType)
--- End of inner exception stack trace ---
at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)
at MS.Internal.XcpImports.MethodEx(DependencyObject obj, String name)
at MS.Internal.XcpImports.DataTemplate_LoadContent(DataTemplate template)
at System.Windows.DataTemplate.LoadContent()
at System.Windows.Controls.DataGridTemplateColumn.GenerateElement(DataGridCell cell, Object dataItem)
at System.Windows.Controls.DataGridColumn.GenerateElementInternal(DataGridCell cell, Object dataItem)
at System.Windows.Controls.DataGrid.PopulateCellContent(Boolean isCellEdited, DataGridColumn dataGridColumn, DataGridRow dataGridRow, DataGridCell dataGridCell)
at System.Windows.Controls.DataGrid.AddNewCellPrivate(DataGridRow row, DataGridColumn column)
at System.Windows.Controls.DataGrid.CompleteCellsCollection(DataGridRow dataGridRow)
at System.Windows.Controls.DataGrid.GenerateRow(Int32 rowIndex, Int32 slot, Object dataContext)
at System.Windows.Controls.DataGrid.GenerateRow(Int32 rowIndex, Int32 slot)
at System.Windows.Controls.DataGrid.InsertDisplayedElement(Int32 slot, Boolean updateSlotInformation)
at System.Windows.Controls.DataGrid.GetExactSlot…
---------------------------
OK
---------------------------