|
Working on a WPF MVVM app...
I have this button:
<Button Background="Transparent"
BorderBrush="Transparent"
Command="{Binding RunCommand}"
Margin="2"
Width="120"
Height="40">
<StackPanel Orientation="Horizontal">
<Image Source="/DemoUI;component/Images/run.png"
Height="32"
Width="32"
Margin="3"/>
<TextBlock Text="Run Test"
VerticalAlignment="Center"/>
</StackPanel>
</Button>
It's bound to RunCommand:
private ICommand _RunCommand;
public ICommand RunCommand
{
get
{
if (_RunCommand == null)
{
_RunCommand = new RelayCommand(runTest, runTestCanExecute);
}
return _RunCommand;
}
}
Here's the methods:
private void runTest()
{
isTesting = true;
var device = (from d in tempDevices
where d.DeviceId == SelectedDevice.DeviceId
select d).FirstOrDefault();
diag.ExecuteTest(device, SelectedTest);
}
private bool runTestCanExecute()
{
return !isTesting;
}
isTesting is defaulted to False. The button does not disable.
Anyone see what's wrong?
If it's not broken, fix it until it is
modified 11-Jul-12 14:53pm.
|
|
|
|
|
Are you sure its not disabled? You are overriding the content, so it may appear to be enabled, but really be not clickable because you aren't handling the disabled state.
|
|
|
|
|
Ya, it's still responds to clicks.
If it's not broken, fix it until it is
|
|
|
|
|
Copy & pasted your code into a test project and it disables just fine. Make sure your DataContext is set properly or it won't know where the command is. I.e. put a break point on your CanExecute handler and make sure its actually getting called.
|
|
|
|
|
Ok, I see what's going on. isTesting is somehow reverting to false by the time the CanExecute is called.
Stay tuned.....
If it's not broken, fix it until it is
|
|
|
|
|
Try this, change you button to use a Click="" event instead of a Command.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I haven't got VS at hand at the moment but couldn't you just do something along the lines of:
<Button IsEnabled="{Binding RunTestButtonEnabled} /Button>
Where RunTestButtonEnabled is a property in your ViewModel.
"You get that on the big jobs."
|
|
|
|
|
Whenever you change isTesting you will need to call
RunCommand.OnCanExecuteChanged()
(If it isn't, you might want to make isTesting a property and call OnExecuteChanged from the Setter)
|
|
|
|
|
Hi All,
I am using datagrid in wpf.actually my requirement is used to show different color in particular cell after every two minutes like first two minutes we need to show blue then Red but values in that cell should not get changed.I have shown the color in the cell using datatrigger through Xaml but i need to add that dynamically into the datatemplate and show the cell coloring.so,if any one knows about this please help me out of it.
Thanks in Advance
Palaniappan
|
|
|
|
|
OK, this is fairly simple to achieve with the use of a Timer, a public property and a value converter. What you need to do is create a property that you will bind to as part of the collection that you are binding your DataGrid against. The timer will be used to change the value of the property.
The value converter simply converts this value into an appropriate colour. Your Background will be bound to the property, and you will use the value converter as your converter.
|
|
|
|
|
Oh I know start the timers slightly offset on each record. Duck dodge weave rock hide under!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: Oh I know start the timers slightly offset on each record. Duck dodge
weave rock hide under
Or just use one timer and update ALL records. I prefer your solution though.
|
|
|
|
|
hiii..
can any one tell me how to make batabse connectivty wid controls lik datagrid....
|
|
|
|
|
|
Hi All
i am converting an Excell spreadsheet into an application. So i am doing automatic calculations like Excell do , for some of the cells(textbox) should allow a user to enter the minus sign "-" , and this automatically minus value entered. So my issue here is if th the users enters that character it breaks my app's calculations. Does anyone have any idea how to bypass this ?
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com
|
|
|
|
|
Vuyiswa Maseko wrote: So my issue here is if th the users enters that character it breaks my app's
calculations. Does anyone have any idea how to bypass this ?
Without knowing how your application works, no. I don't know what code you've actually written, so how can I tell you what's wrong with it. I will say one thing though - if you can cope with positive numbers, you should be able to cope with negative ones. After all, taking away is merely adding a negative number.
|
|
|
|
|
hi Pete
Thanks for your reply. i am just looking at ideas without any coding examples. What i need is a logic to bypass this.
lets take a Cell in an Excel spreadsheet,you normally can enter numeric values and by default anything that has no sign "-" is a "+" so now when it comes to negative in Excel it will subtract the value in the cell from somewhere. So in .e.g asp.net or silverlight , if you want to mimic that Excel behavior how can do that , because immediately when that value is entered it changes the data in the textbox not to fall under "int" or "decima" because there is a special character.
You know what ?
i just Figured out.
i will keep the value as is and when it is being calculated against another Field , i will sum what needs to be summed and subtract on any field that has that sign
Sometimes when you explain the problem to someone you might find the solutiion
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com
|
|
|
|
|
Vuyiswa Maseko wrote: Sometimes when you explain the problem to someone you might find the
solutiion
Often the way my friend, and a 5 for such enlightenment.
|
|
|
|
|
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com
|
|
|
|
|
|
Thanks nice
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com
|
|
|
|
|
How to Comments on image at dynamically write sometext
on image in Silverlight.
|
|
|
|
|
If you just want to display dynamic text over the top of an image that is displayed in the UI, you simply need to place a TextBlock on top of the image and set the Text as appropriate.
|
|
|
|
|
<Grid>
<Image source=""/>
<TextBox Text="Enter comments here.." VerticalAlignment="Center"/>
</Grid>
The above code will put a TextBox in the center of the image where you can enter your comments. Further if you want to have an image with commented text that also you can create a dynamic Bitmap image.
Cheers!
Vinod
http://www.exploresilverlight.com
Cheers!
Vinod
|
|
|
|
|
How To create Image Annotation in Silverlight,Please
Help me.
|
|
|
|