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
729 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
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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…
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 an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

685 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