tle
tle

Reputation: 11

databinding in silverlight

I have a xaml with a button like this:

Button.xaml

<Grid x:Name="LayoutRoot" >
    <StackPanel >
           <Button Content="Button1" Click="Button1_Click" />
    </StackPanel >
 </Grid>

and Button.xaml.cs:

    private void Button1_Click(object sender, RoutedEventArgs e)
    {
        // Get a instance of ClientOversikt
        CustomerView childWindow = m_container.Resolve<CustomerView >();
        childWindow.Show();
    }

It's working fine. But I want to use Databinding in Button.xaml instead of Click="Button1_Click". How could I do it?

I appreciate all the help

Upvotes: 0

Views: 68

Answers (1)

Luke Woodward
Luke Woodward

Reputation: 65044

Since you're using Silverlight 4, you can use commands. You bind the Command property of the Button to an instance of ICommand, which will open the child window when executed. Then, when you click on the button, the command will be executed.

This page contains a reasonably good introduction to commanding.

Upvotes: 3

Related Questions