从xaml中的按钮单击更新datagrid

时间:2015-02-19 19:05:37

标签: datagrid triggers refresh blend

我背后的代码

private void Button_Click(object sender, RoutedEventArgs e)
{
    this.categoriesDataGrid.Items.Refresh();
}

按钮名称为" SaveButton"。我想在xaml代码中这样做。我认为它可以使用触发器或行为甚至混合资产窗格,但我尝试失败了。 感谢

1 个答案:

答案 0 :(得分:0)

我完成了Blend Actions

<Window.Triggers>
    <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="button"/>
</Window.Triggers>

<Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="108,150,0,0" VerticalAlignment="Top" Width="75" Command="{Binding SaveCommand}">
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="Click">
                <ei:CallMethodAction TargetObject="{Binding Items, ElementName=categoriesDataGrid}" MethodName="Refresh"/>
            </i:EventTrigger>
        </i:Interaction.Triggers>
</Button>`