【发布时间】:2018-05-23 09:19:22
【问题描述】:
我有 2 个按钮:
在我看来 MainView.xaml
<StackPanel Grid.Row="2" Grid.Column="3" VerticalAlignment="Center">
<Button Name="wec" Height="50" Content="Podgląd" Margin="15 15 15 0" Command="{Binding ViewCommand}"/>
<Button Height="50" Content="Drukuj" Margin="15 15 15 0" Command="{Binding ElementName=pv, Path=PrintCommand}">
</Button>
</StackPanel>
<local:PrintPreview Grid.Row="4" x:Name="pv" Grid.ColumnSpan="3" PrintingClass="{Binding Model.PrintingClass, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" PrintModel="{Binding Model.PrintingModel, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
我的第一个按钮 - 命令查看文档的打印方式。 第二个按钮 - 命令从 PrintPreview.xaml.cs 打印此文档和下面的代码
private DelegateCommand printCommand;
public DelegateCommand PrintCommand
{
get
{
if (printCommand == null)
printCommand = new DelegateCommand(print);
return printCommand;
}
set
{
if (printCommand != value)
{
printCommand = value;
}
}
}
public bool IsFirstButtonClicked { get; set; }
private bool PrintCommandCanExecute(object unused)
{
return this.IsFirstButtonClicked;
}
private void print(object x)
{
setPageSettings();
WB.Print();
}
这并不完全,但我希望这足以解决解决方案:)
我试过但我不能这样做,意思是:我希望第二个按钮只有在第一个按钮被点击时才处于活动状态。您有什么简单的想法可以做到这一点吗?
【问题讨论】:
标签: wpf button datagrid isenabled