DataBinding Fails but none of the usual causes
The databindings inside my rectangle objects are failing. I suspect the
datacontext isn't being passed along. Here is the high level trace for
DarkSquareColor:
System.Windows.Data Warning: 56 : Created BindingExpression
(hash=15409413) for Binding
(hash=9290279)
System.Windows.Data Warning: 58 : Path: 'DarkSquareColor'
System.Windows.Data Warning: 60 : BindingExpression (hash=15409413):
Default mode resolved to
OneWay
System.Windows.Data Warning: 61 : BindingExpression (hash=15409413):
Default update trigger
resolved to PropertyChanged
System.Windows.Data Warning: 62 : BindingExpression (hash=15409413):
Attach to
System.Windows.Media.SolidColorBrush.Color (hash=62178992)
System.Windows.Data Warning: 64 : BindingExpression (hash=15409413): Use
Framework mentor <null>
System.Windows.Data Warning: 67 : BindingExpression (hash=15409413):
Resolving source
System.Windows.Data Warning: 69 : BindingExpression (hash=15409413):
Framework mentor not found
System.Windows.Data Warning: 65 : BindingExpression (hash=15409413):
Resolve source deferred
System.Windows.Data Warning: 95 : BindingExpression (hash=15409413): Got
InheritanceContextChanged event from SolidColorBrush (hash=62178992)
System.Windows.Data Warning: 67 : BindingExpression (hash=15409413):
Resolving source
System.Windows.Data Warning: 70 : BindingExpression (hash=15409413): Found
data context element:
Rectangle (hash=59316889) (OK)
System.Windows.Data Warning: 71 : BindingExpression (hash=15409413):
DataContext is null
'Chess Piece Viewer.vshost.exe' (Managed (v4.0.30319)):
Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework-
SystemXmlLinq\v4.0_4.0.0.0__b77a5c561934e089\PresentationFramework-SystemXmlLinq.dll'
Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework-
SystemXml\v4.0_4.0.0.0__b77a5c561934e089\PresentationFramework-SystemXml.dll'
System.Windows.Data Warning: 67 : BindingExpression (hash=15409413):
Resolving source
System.Windows.Data Warning: 70 : BindingExpression (hash=15409413): Found
data context element:
Rectangle (hash=59316889) (OK)
System.Windows.Data Warning: 71 : BindingExpression (hash=15409413):
DataContext is null
Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework-
SystemData\v4.0_4.0.0.0__b77a5c561934e089\PresentationFramework-SystemData.dll'
Part of the Failing xaml:
<Border BorderBrush="{Binding Path=ChessBoard.BoardBorderBrush}"
BorderThickness="{Binding
Path=ChessBoard.BoardBorderThickness}" >
<UniformGrid Rows="8" Columns="8" >
<Canvas>
<Rectangle x:Name="a1" Stroke="{Binding
Path=ChessBoard.DarkSquareBorder}">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding
Path=ChessBoard.DarkSquareColor,
diagnostics:PresentationTraceSources.TraceLevel=High}"/>
</Rectangle.Fill>
</Rectangle>
<ContentControl DataContext="{Binding
Path=ChessSquareViewModels[0]}"/>
</Canvas>
</UniformGrid>
</Border>
</UserControl>
ViewModel:
namespace Chess_Piece_Viewer.ViewModels
{
class ChessGameViewModel :BaseViewModel
{
#region BackingFields
private IChessBoard _ChessBoard;
private IChessGame _ChessGame;
private DataTemplateSelector _ChessDataTemplateSelector;
No comments:
Post a Comment