Wie databind öffentliche Eigenschaft in xaml

Alles was ich versuche zu tun, ist binden ein public-Eigenschaft eines textBlock zugewiesen. Was mache ich hier falsch?

namespace WpfApplication1
{

    public partial class MainWindow : Window
    {

        public string test { get; set; }

        public MainWindow()
        {
            test = "this is a test";
            InitializeComponent();
        }
    }
}

<Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
<Window.Resources>
    <ObjectDataProvider x:Key="test"></ObjectDataProvider>
</Window.Resources>
<Grid>
    <TextBlock Height="23" HorizontalAlignment="Left" Margin="108,58,0,0" Name="textBlock1"  VerticalAlignment="Top" Text="{Binding Source={StaticResource test}}" />
</Grid>

InformationsquelleAutor Morgan Herlocker | 2011-01-19

Schreibe einen Kommentar