小编Mar*_*ons的帖子

WPF选择DataGrid中的所有CheckBox

我正在尝试在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的图片

在此输入图像描述

有没有办法以编程方式选择所有复选框?

编辑 我已经尝试按照这个步骤

你可以看到我的代码是相同的,但对我不起作用

c# wpf xaml datagrid

8
推荐指数
2
解决办法
5373
查看次数

找不到方法:'System.Collections.ObjectModel.Collection`1

嗨,当我发布它时,我在我的 WebService 上收到此跟随错误,

  • 找不到方法:'System.Collections.ObjectModel.Collection`1 System.Net.Http.Formatting.MediaTypeFormatter.get_SupportedMediaTypes()'。 在此处输入图片说明

但是当我在 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)

c# web-services

2
推荐指数
1
解决办法
1945
查看次数

PHP laravel 自动路由

我正在使用 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)

有没有办法识别这些行为?

php laravel laravel-5

0
推荐指数
1
解决办法
5417
查看次数

标签 统计

c# ×2

datagrid ×1

laravel ×1

laravel-5 ×1

php ×1

web-services ×1

wpf ×1

xaml ×1