我想在xaml文件中关闭窗口/对话框。实际xaml: ...
<Button Name="CancelButton" Content="Cancel" Controls1:ButtonUtils.DialogResult="False" />
没有实现此按钮的功能,例如:
<Button Name="CancelButton" Content="Cancel" Controls1:ButtonUtils.DialogResult="False" Click="CancelButton_Click" />
private void CancelButton_Click(object sender, RoutedEventArgs e)
{
Close();
}
现在CANCEL按钮与OK按钮完全相同(保存内容并关闭窗口)。我想改变一下的行为 取消按钮 - 只是关闭窗口。除了xaml文件之外,CANCEL按钮没有实现。 带OK和CANCEL按钮的XAML: ...
<Controls:WindowFooter>
<Button Content="Ok" Name="OkButton" IsDefault="true" Controls1:ButtonUtils.DialogResult="True" >
<Button.IsEnabled>
<MultiBinding>
<MultiBinding.Converter>
<Converters:ErrorMultiConverter/>
</MultiBinding.Converter>
<Binding ElementName="test1" Path="(Validation.HasError)"/>
<Binding ElementName="test2" Path="(Validation.HasError)"/>
<Binding ElementName="test3" Path="(Validation.HasError)"/>
<Binding ElementName="test4" Path="(Validation.HasError)"/>
</MultiBinding>
</Button.IsEnabled>
</Button>
<Button Name="CancelButton" Content="Cancel" Controls1:ButtonUtils.DialogResult="False" />
</Controls:WindowFooter>
我期待的是:
<Button Name="CancelButton" Content="Cancel" Controls1:ButtonUtils.DialogResult="False" [Method=CloseWindow()] />
答案 0 :(得分:2)
也许Button.IsCancel
属性可以帮到你吗?
<Button Name="CancelButton" Content="Cancel" Controls1:ButtonUtils.DialogResult="False" IsCancel=True"/>