Binding in ContentControl Crash

Posted by ImJames on Stack Overflow See other posts from Stack Overflow or by ImJames
Published on 2010-12-23T14:48:38Z Indexed on 2010/12/23 14:54 UTC
Read the original article Hit count: 198

Filed under:
|
|
|

Can anyone tell me why this crashes my app? There seems to be some endless recursion by I can't figure out why. I get this exception

Logical tree depth exceeded while traversing the tree. This could indicate a cycle in the tree

<ContentControl Content="{Binding}">
    <ContentControl.ContentTemplate>
        <DataTemplate>
            <Button Content="{Binding MyString}"/>
        </DataTemplate>
    </ContentControl.ContentTemplate>
</ContentControl>

And this is all I have as Source

    public MainWindow()
    {
        InitializeComponent();
        MyString = "Test";
        this.DataContext = this;
    }

    public string MyString { get; set; }

© Stack Overflow or respective owner

Related posts about wpf

Related posts about xaml