Trying to understand data binding and this totally seems like a rookie mistake but I have no idea why it's happening.
CS
namespace MuhProgram
{
public partial class MainWindow : Window
{
public string foobar
{
get { return "loremipsum"; }
}
public MainWindow()
{
InitializeComponent();
}
}
}
XAML:
<Window x:Class="MuhProgram.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MuhProgram"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<local:MainWindow x:Key="classMainWindow"/>
</Window.Resources>
<Grid>
<Label Content="{Binding Source={StaticResource classMainWindow}, Path=foobar}"></Label>
</Grid>
</Window>
Debugger points at InitializeComponent() call in MainWindow() method with StackOverflowException.
I also tried setting DataContext attribute to "{StaticResource classMainWindow}" in the grid but the effect is the same.