çalışmıyor XAML geçerli:Burada
<DataGrid Grid.Column="0" AutoGenerateColumns="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemsSource="{Binding Path=Columns}"
x:Name="ColumnsGrid" RowHeaderWidth="0">
<DataGrid.Columns>
<DataGridTextColumn Width="*" Binding="{Binding Path=Header}"
Header="{Binding ElementName=ColumnsGrid, Path=DataContext.Count, StringFormat=Columns ({0}), diag:PresentationTraceSources.TraceLevel=High}"/>
</DataGrid.Columns>
</DataGrid>
Cilt döner hatası: System.Windows.Data hatası: 2: Hedef elemanı için FrameworkElement veya FrameworkContentElement yöneten bulunamıyor.
Neyi özlüyorum?
Güncelleme: http://blogs.msdn.com/b/jaimer/archive/2008/11/22/forwarding-the-datagrid-s-datacontext-to-its-columns.aspx
What is happening here? The Columns collection is just a property in the Datagrid; this collection is not in the logical (or visual) tree, therefore the DataContext is not being inherited, which leads to there being nothing to bind to.
Güncelleme 2: DataGrid'in uyarılar hakkında İyi madde: Burada
cevaptır http://blogs.msdn.com/b/vinsibal/archive/2009/04/07/5-random-gotchas-with-the-wpf-datagrid.aspx
Ben ElementName' * Aynı öğesi içinde * çalışır 'sanmıyorum ...
bu göster ... özel bir işleme ihtiyaç . – ChrisFİşte cevap: http://blogs.msdn.com/b/jaimer/archive/2008/11/22/forwarding-the-datagrid-s-datacontext-to-its-columns.aspx > Ne nedir? burada mı oluyor? Kolonlar koleksiyonu sadece Datagrid'de bir > mülküdür; Bu koleksiyon mantıksal (veya görsel) > ağacında değil, bu nedenle DataContext'e miras alınmıyor, bu da > 'a bağlanacak hiçbir şey olmaması anlamına geliyor. –