【问题标题】:databinding in silverlightSilverlight 中的数据绑定
【发布时间】:2011-06-19 09:26:50
【问题描述】:

我有一个带有这样按钮的 xaml:

Button.xaml

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

和 Button.xaml.cs:

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

一切正常。但我想在 Button.xaml 中使用数据绑定而不是 Click="Button1_Click"。我该怎么办?

感谢所有帮助

【问题讨论】:

    标签: silverlight data-binding silverlight-4.0


    【解决方案1】:

    由于您使用的是 Silverlight 4,因此您可以使用 commands。您将ButtonCommand 属性绑定到ICommand 的一个实例,该实例将在执行时打开子窗口。然后,当您单击按钮时,将执行命令。

    This page 包含相当不错的指挥介绍。

    【讨论】:

    • @tle:上面第二个链接中有代码。这还不够吗?
    • 好的。谢谢你。我去看看。
    猜你喜欢
    • 1970-01-01
    • 2010-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-14
    相关资源
    最近更新 更多