Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8007765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:56:04+00:00 2026-06-04T17:56:04+00:00

I have a DataGrid with 4 columns, the first two of them are bound

  • 0

I have a DataGrid with 4 columns, the first two of them are bound to an object.
The other two are button columns are made like this

<DataGridTemplateColumn  MaxWidth="100" Header="Delete">
    <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <Button Name="BtnDelete" CommandParameter="{Binding Path=Id}" Content="Delete" Click="BtnDeleteEmployee_Click" />
        </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

My Datagrid has CanUserAddRows=”True” which always generates an empty row in the bottom of the grid.
However, I would like the two buttons on the bottom row to be disabled until the other rows have been filled. As it is now, I’m (of course) getting a nullreferenceexception when I click the button.

I guess a solution would be to bind the button’s IsEnabled property to

id>0

But how to do this, I am not sure.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:56:05+00:00Added an answer on June 4, 2026 at 5:56 pm

    One way to accomplish this is to bind the IsEnabled property to the Id property and use a ValueConverter to retun True or False based on your criteria.

    A value converter could look like this:

    public class IdToEnabledConverter:IValueConverter
    {
      public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
        return value != null && (int)value > 0;
      }
    
      public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
        throw new NotImplementedException();
      }
    }
    

    and you reference it in your resources section:

    <Grid.Resources>
      <local:IdToEnabledConverter x:Key="IdToEnabledConverter"/>
    </Grid.Resources>
    

    And bind the IsEnabled property:

    <Button IsEnabled="{Binding Id, Converter={StaticResource IdToEnabledConverter}}"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataGrid bound to a DataView which, among other columns has, an
I have two datagrids with one column each. First: <DataGrid.Columns> <DataGridTextColumn x:Name=FilterTextCol01 IsReadOnly=False Width={Binding
We have a Flex DataGrid with 3 columns of which one of them has
I have a datagrid in C#.net I have made some columns in grid editable.
I have a datagrid with an XML object as dataprovider. There are 2 columns
I have a flex datagrid with 3 columns. The first column contains the image
I have a datagrid with 2 columns. One column contains role information, the other
I have a WPF 4.0 DataGrid with AutoGenerated columns. I would like to only
I am creating a datagrid with three columns. The first two columns are not
I have a datagrid with 5 columns. The first column has checkboxs and rest

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.