Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
Medium Priority
?
747 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
with earned 2000 total points
ID: 33479618
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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

610 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