我正在尝试在DataGrid中选择所有CheckBox,但我没有使用此代码获得任何结果
这是我在单击主CheckBox时调用的函数
private void CheckUnCheckAll(object sender, RoutedEventArgs e)
{
CheckBox chkSelectAll = ((CheckBox)sender);
if (chkSelectAll.IsChecked == true)
{
dgUsers.Items.OfType<CheckBox>().ToList().ForEach(x => x.IsChecked = true);
}
else
{
dgUsers.Items.OfType<CheckBox>().ToList().ForEach(x => x.IsChecked = false);
}
}
Run Code Online (Sandbox Code Playgroud)
dgUsers是DataGrid,但我发现任何复选框都找到了.
这是我正在使用的XAML在数据网格中创建CheckBox
<DataGrid.Columns>
<DataGridCheckBoxColumn x:Name="col0" HeaderStyle="{StaticResource ColumnHeaderGripperStyle}">
<DataGridCheckBoxColumn.HeaderTemplate>
<DataTemplate>
<CheckBox Click="CheckUnCheckAll" >
</CheckBox>
</DataTemplate>
</DataGridCheckBoxColumn.HeaderTemplate>
</DataGridCheckBoxColumn>
<DataGrid.Columns>
Run Code Online (Sandbox Code Playgroud)
这是我的DataGrid的图片
有没有办法以编程方式选择所有复选框?
编辑 我已经尝试按照这个步骤
你可以看到我的代码是相同的,但对我不起作用
嗨,当我发布它时,我在我的 WebService 上收到此跟随错误,

但是当我在 VS 调试模式下使用它时,它不会发生。我已经在 google 上搜索过它并尝试在 webconfig 上使用程序集引用,但它没有任何提示?
这是我当前的 webconfig 文件
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<system.web>
<customErrors mode="Off"/>
</system.web>
<system.webServer>
<httpErrors errorMode="Detailed" />
</system.webServer>
<system.web>
<httpRuntime executionTimeout="3000000" maxRequestLength="1048576" />
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<authentication mode="Windows" />
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
</system.web>
<runtime>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0"/>
</dependentAssembly>
</runtime>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttp" …Run Code Online (Sandbox Code Playgroud) 我正在使用 laravel 5.5,我正在尝试使用到控制器的自动路由,但它不起作用
在 web.php(此版本的路由文件)中,我有以下行
Route::resource('panel', 'panel');
Route::resource('/', 'HomeController');
Run Code Online (Sandbox Code Playgroud)
在面板中我有以下操作
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
class panel extends Controller{
public function index(){
return \View::make('panel.index');
}
public function registrar(){
return \View::make('panel.registrar');
}
}
Run Code Online (Sandbox Code Playgroud)
但它只是调用index()视图,当用户访问 url 时,不会调用 registrar() 视图
site.com/panel/registrar
Run Code Online (Sandbox Code Playgroud)
屏幕上打印以下错误
"Method [show] does not exist on [App\Http\Controllers\panel]."
Run Code Online (Sandbox Code Playgroud)
我尝试使用 base_controller 但它也不起作用
"Class 'App\Http\Controllers\Base_Controller' not found"
Run Code Online (Sandbox Code Playgroud)
有没有办法识别这些行为?