Click here to Skip to main content
15,889,876 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to show this on WPF page about this is code behind. Please, can someone tell the best way to do it? Thank you

<pre> public partial class About : Page
    {
        public About()
        {
            InitializeComponent();
            //About.Title = String.Format("About {0}", AssemblyTitle);
            //string Title = String.Format("About {0}", AssemblyTitle);
            //this.lblTitle.Text = String.Format("About {0}", AssemblyVersion);
        }

        #region Assembly Attribute Accessors

        public string AssemblyTitle
        {
            get
            {
                object[] attrinbutes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);

                if(attrinbutes.Length > 0)
                {
                    AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attrinbutes[0];
                }

                return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
            }
        }
        
        public string AssemblyVersion
        {
            get
            {
                return Assembly.GetExecutingAssembly().GetName().Version.ToString();
            }
        }

        public string AssemblyDescription
        {
            get
            {
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);

                if (attributes.Length == 0)
                {
                    return "";
                }
                return ((AssemblyDescriptionAttribute)attributes[0]).Description;
            }
        }

        public string AssemblyProduct
        {
            get
            {
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
                if (attributes.Length == 0)
                {
                    return "";
                }
                return ((AssemblyProductAttribute)attributes[0]).Product;
            }
        }

        public string AssemblyCopyright
        {
            get
            {
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
                if (attributes.Length == 0)
                {
                    return "";
                }
                return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
            }
        }

        public string AssemblyCompany
        {
            get
            {
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
                if (attributes.Length == 0)
                {
                    return "";
                }
                return ((AssemblyCompanyAttribute)attributes[0]).Company;
            }
        }
        #endregion
    }


What I have tried:

Stack and other internet things
Posted
Updated 25-Apr-19 1:34am
Comments
[no name] 17-Apr-19 19:14pm    
Implement INotifyPropertyChanged interface. Set DataContext. Call on property changed. Use properties instead of heavy-weight getters.

1 solution

just set the DataContext of the Page to itself (DataContext = this;), Use {Binding AssemblyCopyright} etc. in the page's XAML. What won't work is a two-way binding but it seems you don't want to edit these fields anyway. So you can get this to work in seconds.
 
Share this answer
 
Comments
Member 12823969 25-Apr-19 9:21am    
I was Implement INotifyPropertyChanged interface. Set DataContext. Call on property changed. and then Usercontrol.Resources but your DataContext and Biniding are also included so, thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900