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
732 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 500 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
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…

738 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