Solved

How do I set the binding source of a label in WPF to this value System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion?

Posted on 2010-08-19
1
719 Views
Last Modified: 2013-11-12
I wanted to set the value of label in WPF to the value that System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion would give you?

How would I do that in XAML?
0
Comment
Question by:endrec
1 Comment
 
LVL 3

Accepted Solution

by:
with earned 500 total points
Comment Utility
I would suggest using the MVVM pattern for a piece of data like that.  

In the following example I'm creating a new class to facilitate a DataContext; if you have an existing object you're using as DataContext already, you can add a Version property to that (instead of creating an entirely separate class just to house the Version).  But this just illustrates the concept:

public class MyViewModel
{
	public Version MyCurrentVersion 
	{ 
		get { return System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion; }
	}
}

(then, in XAML)

<Grid>
	<Grid.DataContext>
		<local:MyViewModel/>
	</Grid.DataContext>
	<TextBlock Text={Binding MyCurrentVersion} />
</Grid>

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now