我的模型为:
namespace Forecast.MVVM.WPF.ViewModel
{
public class ApplicationInfoViewModel
{
private string versionNumber;
public ApplicationInfoViewModel()
{
versionNumber = Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
public string VersionNumber
{
get { return versionNumber; }
set { versionNumber = value; }
}
}
我的观点是,我正在设置 datContext 并将值设置为;
<UserControl .... xmlns:AppInfo="clr-namespace:Forecast.MVVM.WPF.ViewModel" .../>
<UserControl.Resources>
<AppInfo:ApplicationInfoViewModel x:Key="forecastVersionInfo"/>
</UserControl.Resources>
<Grid>
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding VersionNumber}" VerticalAlignment="Bottom"/>
</Grid>
但我看不到值