是否可以将TextBlock的Text绑定到应用程序AssemblyVersion?

use*_*er1 3 c# data-binding wpf version-numbering

如果我在UserControl的角落有一个TextBlock,可以将Text属性绑定到AssemblyInfo.cs中的Assembly Version Number

WPF:

<TextBlock Text="{Binding AssemblyVersion}"/>
Run Code Online (Sandbox Code Playgroud)

AssemblyInfo.cs中

[assembly: AssemblyVersion("1.0.0.0")]
Run Code Online (Sandbox Code Playgroud)

Sri*_*vel 7

创建一个名为readonly的属性AssemblyVersion并绑定它.

public Version AssemblyVersion
{
    get
    {
        return Assembly.GetEntryAssembly().GetName().Version;
    }
}
Run Code Online (Sandbox Code Playgroud)