所以我对XAML
很陌生,我需要一些帮助解决以下问题。
我有三个按钮,只要一个项目有效并准备好保存就应该更新,这对于按钮和#34;保存"和"关闭"但按钮" SaveAndClose"不会与其他人一起更新,为什么会这样?
<Window.CommandBindings>
...
<CommandBinding Command="{x:Static l:PartWindow.SaveAndCloseCommand}" Executed="SaveAndCloseExecuted" CanExecute="SaveAndCloseCanExecute"/>
</Window.CommandBindings>
...
<Grid>
...
<np:NewPartsDetailsControl x:Name="NewPartsDetailsCtrl" Margin="30" Visibility="{Binding Path=DataContext.Part.IsNew, ElementName=thisCntrl, Converter={StaticResource VisibilityConverter}}"/>
...
<Grid Grid.Row="1">
...
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
<StackPanel.Resources>
<Style TargetType="Button" BasedOn="{StaticResource MainButton}">
<Setter Property="CommandTarget" Value="{Binding ElementName=PartsDetailsCtrl}" />
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Part.IsNew}" Value="True">
<Setter Property="CommandTarget" Value="{Binding ElementName=NewPartsDetailsCtrl}" />
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Resources>
...
<Button Command="{x:Static l:PartWindow.SaveAndCloseCommand}"
Content="{x:Static p:Resources.SaveAndClose}"
IsCancel="True"/>
<Button Command="ApplicationCommands.Save"
Content="{x:Static p:Resources.Save}" />
<Button Command="ApplicationCommands.Close"
Content="{x:Static p:Resources.Close}"
IsCancel="True"/>
</StackPanel>
...
</Grid>
using System.Windows.Input;
namespace WpfApp.Views.Parts
{
public partial class PartWindow : SizeAdjustableWindow
{
public static RoutedCommand SaveAndCloseCommand = new RoutedCommand();
}
}