Solved

Setting a Buttons CommandParameter to its own Tag or Content Property in a WPF application

Posted on 2016-11-19
3
35 Views
Last Modified: 2016-11-26
In a very simple WPF application I am binding a Button to a Command. I would like to set this button's CommandParameter to this buttons' own tag or content property. I would appreciate help with syntax for this.
Thank you for your help.
0
Comment
Question by:FaheemAhmadGul
  • 2
3 Comments
 
LVL 80

Expert Comment

by:David Johnson, CD, MVP
ID: 41894297
Windows is event driven so when you mouseover or click the button it fires an event so in your code behind you set the actions based on the event
0
 

Accepted Solution

by:
FaheemAhmadGul earned 0 total points
ID: 41896884
<Button Grid.Row="7" Background="Green" Command="{Binding SaveCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self},  Path=.}" >Good</Button>

Open in new window


Perhaps my question was not very clear. I was asking about using Command using MVVM pattern in a WPF application. I did manage to find the solution in the end and that is as I have posted in the code Section.
0
 

Author Closing Comment

by:FaheemAhmadGul
ID: 41902218
No body posted the correct solution. In the end I managed to find a solution on StackOverflow and have posted here and accepted it.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

679 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