小编Mus*_*mil的帖子

按箭头键时文本框Keydown事件未触发

我有一个datagrid,其中一列作为DataGridTemplateColumn,如下所示:

<my:DataGrid Name="dgvSales"   RowHeight="23"  SelectionUnit="Cell"  BeginningEdit="dgvSales_BeginningEdit"  AutoGenerateColumns="False"   CellEditEnding="dgvSales_CellEditEnding" >
                   <my:DataGrid.Columns>
                        <my:DataGridTemplateColumn Header="Product Name" Width="200">
                            <my:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Product_Name}"></TextBlock>
                                </DataTemplate>
                            </my:DataGridTemplateColumn.CellTemplate>
                            <my:DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate>
                                    <TextBox x:Name="txtbxProduct" Text="{Binding Product_Name}" TextChanged="txtbxProduct_TextChanged" KeyDown="txtbxProduct_KeyDown"></TextBox>
                                </DataTemplate>
                            </my:DataGridTemplateColumn.CellEditingTemplate>
                        </my:DataGridTemplateColumn>
                 </my:DataGrid.Columns>
</my:DataGrid>
Run Code Online (Sandbox Code Playgroud)

当单元格值更改时,我想将一些项目填充到列表视图中,TextChanged事件如下:

 private void txtbxProduct_TextChanged(object sender, TextChangedEventArgs e)
    {
        TextBox tb = (TextBox)sender;
        if (tb.Text.Trim() != "")
        {
            string qry = "select PL.Record_Id as PList_Id,PM.Record_Id as Product_Id,PM.Product_Code,PM.Product_Name,PTM.Product_Type,PL.Purchase_Rate ,PL.Selling_Rate,PL.MRP  from dbo.Tbl_Product_Master PM  join Tbl_Product_List PL on PL.Product_Id=PM.Record_Id   join Tbl_Product_Type_Master PTM on PTM.Record_Id=PM.Product_Category_Id where PL.Batch_Flag=0  and PM.Is_Del='false'and PM.Is_Active='true'  and …
Run Code Online (Sandbox Code Playgroud)

c# wpf datagrid

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

wpf datagrid:在wpf中创建一个DatagridNumericColumn

我要求我创建一个只接受数值(整数)的datagridcolumn,当​​用户输入除数字之外的其他内容处理文本框时.我尝试了很多网页,我厌倦了这些,我非常感谢任何有帮助的人.

c# validation wpf datagrid

9
推荐指数
1
解决办法
1万
查看次数

将动态数据绑定到rowdetails模板中的wpf datagrid

我有一个数据网格说Datagrid1,其中填充了List(动态地通过代码隐藏).在datagrid的行详细信息模板里面,我想添加一个datagrid,让我们调用datagrid2,datagrid2需要在Datagrid1的SelectionChange事件上用List动态地进行poupulated?访问datagrid2并将其绑定到数据源需要在后面的代码中完成.可以用这个来帮助我吗?我的xaml是:

<Grid>
        <my:DataGrid    Name="dataGrid1" ItemsSource="{Binding}">
            <my:DataGrid.RowDetailsTemplate>
                <DataTemplate>
                    <my:DataGrid Name="dataGrid2"></my:DataGrid>
                </DataTemplate>
            </my:DataGrid.RowDetailsTemplate>
        </my:DataGrid>
    </Grid>
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml datagrid wpftoolkit

4
推荐指数
1
解决办法
1万
查看次数

如何在owin启动类中注入依赖项

在我的Web API应用程序中,我实现了OAuth2。在ApplicationOAuthProvider的GrantResourceOwnerCredentials上,我正在调用我的自定义成员资格服务以登录并获取令牌。问题是我必须将成员资格服务注入ApplicationOAuthProvider才能使用该服务,但由于owinStartup类的原因而不允许使用它不支持参数构造函数。如何在GrantResourceOwnerCredentials方法中注入/使用我的成员资格服务。

  public class ApplicationOAuthProvider : OAuthAuthorizationServerProvider
  {
      private readonly string _publicClientId;
      private readonly IMembershipService _membershipService;

      public ApplicationOAuthProvider(string publicClientId, 
           IMembershipService membershipService)
      {
        if (publicClientId == null)
        {
            throw new ArgumentNullException("publicClientId");
        }

        _publicClientId = publicClientId;
        this._membershipService = membershipService;
      }

      public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
      {
            AccountLogin LogCredentials = new AccountLogin();
            LogCredentials.UserName = context.UserName;
            LogCredentials.Password = context.Password;

            ProviderLoginResponse providerLoginResponse = 
                _membershipService.UserLogin(LogCredentials);
            if (providerLoginResponse.LoginStatus != "Y")
            {
                context.SetError("invalid_grant", "The user name or password 
                is incorrect.");
                return;
            }

            var claims = new List<Claim>() …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc dependency-injection oauth-2.0 asp.net-web-api owin

3
推荐指数
1
解决办法
2117
查看次数