Solved

XAML Button Content

Posted on 2013-01-30
7
407 Views
Last Modified: 2013-01-31
The text displayed in an XAML button is set by the Content property (or so I believe).
What is the correct way to do something like....

if mButton.Content = "Press Me" then

The above doesn't work :(
0
Comment
Question by:Dodsworth
  • 3
  • 3
7 Comments
 
LVL 9

Expert Comment

by:gt2847c
ID: 38835223
Not sure what you're trying to do...  what you have above appears to be trying to set the text of the button in an "if" statement.

This would set the text on the button:
mButton.Content = "Press me";

This would test to see if the text on the button is "Press me";
if(mButton.Content == "Press Me")
{ // do something }
0
 
LVL 1

Author Comment

by:Dodsworth
ID: 38835585
I'm trying to test if the button's text is "Press Me" but it Errors as

Error      1      Requested operation is not available because the runtime library function 'Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectEqual' is not defined.
0
 
LVL 9

Expert Comment

by:gt2847c
ID: 38835614
Ah, VB, not C#...  Not my specialty, but...

Try this:
if mButton.Text.Equals("Press Me") then

Or
if String.Equals(mButton.Text, "Press Me") then
0
DevOps Toolchain Recommendations

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

 
LVL 1

Author Comment

by:Dodsworth
ID: 38835743
There is no .text on an xaml button.  It's called Content as far as I can see.
0
 
LVL 27

Accepted Solution

by:
nmarun earned 500 total points
ID: 38835783
Content holds an object. You have to call a .ToString() on it.

Try this:

if mButton.Content.ToString() = "Press Me" then

Arun
0
 
LVL 9

Expert Comment

by:gt2847c
ID: 38835787
You are correct...  being that I don't do VB (other than occasionally read it), I tested the code under forms which uses .Text...  Content is correct for XAML so:

If mButton.Content.Equals("Press Me") Then
     code goes here
End If
0
 
LVL 1

Author Comment

by:Dodsworth
ID: 38838886
If mButton.Content.Equals("Press Me") Then does not fire :
(
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Open a word document 23 33
Error in page 3 46
.Net Web Site IIS Web.Config Content-Security-Policy 1 44
Advice on Xojo as a development tool over VB. 4 39
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

895 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

16 Experts available now in Live!

Get 1:1 Help Now