我已经创建了带有文本框的窗口,我正在使用 MVVM 模式,为了填充它,我有包含对象的视图模型类,现在我需要将它与 Text 属性绑定
public log Event
{
get { return mEvent; }
set { mEvent = value; }
}
弹出一个窗口来显示数据现在我想在窗口中填充数据
<TextBlock x:Name="xCategyTextBox" Grid.Column="1" Grid.Row="0" TextAlignment="Center" Margin="5" Text="{Binding Path=Event.Category}"/>
<TextBlock x:Name="xLevTextBox" Grid.Column="1" Grid.Row="1" TextAlignment="Center" Margin="5" Text="{Binding Path=Event.Type}"/>
在 Xaml.cs 中
WindowsEventsAutoMountViewModel windows = new WindowsEventsAutoMountViewModel(logEntry);
this.DataContext = windows.Event;