Jul 4, 2010 at 6:58 PM
Edited Jul 4, 2010 at 7:01 PM
Using White 0.2, VS 2010, Win7 64 bit
I have a simple form with a textbox and an "Add Item" button beside it in a WPF App. Now I have wired it up such that the button is enabled only if the textbox contains a numeric value.
The button's command has the Execute and CanExecute code blocks as shown. (ItemNumber is a property bound to the text field)
this.AddItemCommand = new RelayCommand(SnipeNewItem, // execute
return Int32.TryParse(ItemNumber, out itemNo);
When I manually run the app, this works perfectly. The button is enabled as soon as I type in a numeric value in the text field.
However when run via White, I ran into some issues
var textBox = _window.Get<TextBox>("_itemToSnipe");
//textBox.Text = itemNo.ToString(); // this didnt set the text
//textBox.BulkText = itemNo.ToString(); // set the text but didnt enable the button
textBox.SetValue(itemNo.ToString()); // same as above.
var addItemButton = _window.Get<Button>("_btnAddItem");
//addItemButton.Click(); // didnt work
addItemButton.RaiseClickEvent(); // works. However will throw if the button is not enabled at this point.
I realize that some part of this has something to do with
However RaiseClickEvent() seems to have solved that problem, its the databinding canExecute not triggering that is holding me up now.
Any ideas ?