是否可以绑定到此:
<Frame Content="{Binding CurrentContent}" />
而不是:
<Frame Source="{Binding CurrentContentUri}" />
在我的视图模型中,我会有类似的东西:
private ContentControl currentPage;
public ContentControl CurrentContent
{
get
{
return this.currentPage;
}
protected set
{
this.Set<ContentControl>(ref this.currentPage, value);
}
}
并将其触发为:
this.CurrentContent = new ContentControl() { Content = new AccountWidgetPage() };
然而,有两个问题:
InvalidOperationException:Page只能有Window或Frame 父节点。
new ContentControl()
对我来说似乎不对。基本上,我如何动态更新Frame
的内容绑定,而不将其指向XAML(我想使用非默认构造函数,因为我已经安装了DI)。
答案 0 :(得分:1)
将CurrentContent属性的类型更改为object或Page,并将其分配给Page的实例,例如:
<?php
namespace App\Http\Middleware;
use Closure;
class SomeMiddleware
{
public function handle($request, Closure $next)
{
// Here, you can perform action before passing it to the controllers
$response = $next($request);
// Here, you get back the response generated by the controllers
// and you can add cookies or anything you want
return $response;
}
}