What you're describing is very doable, but...first of all, make sure that isUpdatable is a public property that is (a) on the current DataContext, (b) properly raises a PropertyChanged event when it gets updated (or is a DependencyProperty), and (c) is set to the desired initial value. Your web service call will be asynchronous (web service calls in Silverlight are Async) so if you're using anything other than the vanilla Async Model (where you hook an event prior to making your call and set your value within the event handler - and the event handler is guaranteed to be on the UI thread) you may need to marshal your value back to the UI thread to prevent a nasty exception.
Just remember that because of the async nature of the call, the button will update to its desired value only after the call returns, so set the initial value correctly (enabled or disabled, depending on your needs.)
Here's a quick & dirty sample (the service call merely toggles the value it receives as its parameter):
Codebehind:
public partial class MainPage : UserControl, INotifyPropertyChanged
{
public MainPage()
{
InitializeComponent();
}
private bool _isUpdatable;
public Boolean IsUpdatable
{
get { return _isUpdatable; }
set
{
if (_isUpdatable != value)
{
_isUpdatable = value;
if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("IsUpdatable"));
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void CallTheService_Click(object sender, RoutedEventArgs e)
{
var serviceProxy = new Service1Client();
serviceProxy.ToggleCompleted += new EventHandler<ToggleCompletedEventArgs>(serviceProxy_ToggleCompleted);
serviceProxy.ToggleAsync(IsUpdatable);
}
private void serviceProxy_ToggleCompleted(object sender, ToggleCompletedEventArgs e)
{
if (e.Error == null)
{
IsUpdatable = e.Result;
}
}
}
XAML:
<Grid x:Name="LayoutRoot" Background="White" DataContext="{Binding ElementName=window1}">
<Button IsEnabled="{Binding IsUpdatable}" Content="Foo" Height="100" VerticalAlignment="Top"/>
<Button Content="Toggle Foo" Height="100" VerticalAlignment="Bottom" Click="CallTheService_Click" />
</Grid>