感谢您的光临。 如果尝试在其他位置选中复选框,则试图在WPF摇动中创建一个按钮。我尝试仅在XAML中执行此操作,但无法弄清楚如何同时检查单击作为触发器和复选框。这是我的XAML代码:
<Style TargetType="{x:Type Button}">
<Setter Property="RenderTransformOrigin"
Value="0.5 0.5" />
<Setter Property="RenderTransform">
<Setter.Value>
<RotateTransform />
</Setter.Value>
</Setter>
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property='IsPressed'
Value='True' />
</MultiTrigger.Conditions>
<MultiTrigger.EnterActions>
<BeginStoryboard>
<Storyboard TargetProperty="RenderTransform.Angle">
<DoubleAnimation From="0"
To="5"
Duration="0:0:0.05"
AutoReverse="True"
FillBehavior="Stop" />
<DoubleAnimation BeginTime="0:0:0.05"
From="5"
To="-5"
Duration="0:0:0.1"
AutoReverse="True"
FillBehavior="Stop" />
<DoubleAnimation BeginTime="0:0:0.2"
From="-5"
To="0"
Duration="0:0:0.1"
AutoReverse="False"
FillBehavior="Stop" />
</Storyboard>
</BeginStoryboard>
</MultiTrigger.EnterActions>
</MultiTrigger>
</Style.Triggers>
这使按钮在按下时总是摇晃。为了使它有条件地工作,我认为我应该在后面的代码中实现它。我认为动画一旦开始工作,就应该像添加if语句一样简单。
MainWindow : Window
{
private Storyboard myStoryboard;
public MainWindow()
{
InitializeComponent();
DoubleAnimation myDoubleAnimation = new DoubleAnimation();
myDoubleAnimation.From = 0.0;
myDoubleAnimation.To = 20.0;
myDoubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(5));
myDoubleAnimation.AutoReverse = true;
myStoryboard = new Storyboard();
myStoryboard.Children.Add(myDoubleAnimation);
Storyboard.SetTargetName(myDoubleAnimation, HelpButton.Name);
Storyboard.SetTargetProperty(myDoubleAnimation, new
PropertyPath(RotateTransform.AngleProperty));
HelpButton.Click += ShakeObject;
}
private void ShakeObject(object sender, RoutedEventArgs e)
{
myStoryboard.Begin(this);
}
}
我希望这段代码可以将我的名为“ HelpButton”的按钮(在XAML中)旋转20度,然后向后旋转,但是没有这种运气。
我可以执行一个RotateTransform .BeginAnimation(RotateTransform.AngleProperty,myDoubleAnimation); 但我想连续进行几次旋转(以模拟晃动)。
感谢您的帮助!谢谢。
答案 0 :(得分:0)
我发现的一种解决方案是,当IsChecked触发我的复选框时,将XAML样式应用于按钮,然后取消选中该样式。
答案 1 :(得分:0)
您需要在复选框上添加条件,然后在MultiDataTrigger中更改MultiTringger。 这是代码
public function store(Request $request)
{
$requestData = $request->all();
$requestData['application_id'] = strtolower(trim($requestData['application_id'].'.'.config('app.fqdn_base')));
$request->replace($requestData);
$values = $this->validate($request, [
'application_type' => 'required|exists:applications,name',
/* other validations */
]);
$exitCode = Artisan::call('tenant:create', [
/* passing param here */
]);
$host = Hostname::where('fqdn', $values["application_id"])->first();
$web = $host->website;
$web->name = $values["application_name"];
$web->application_id = Application::where('name', '=', $values["application_type"])->pluck('id')->first();
$web->owner = auth()->id();
$web->save();
$applications = Application::where('id', '!=', '0')->get();
return view('admin.applications', [ "applications" => $applications]);
}