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 9103639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:40:48+00:00 2026-06-17T01:40:48+00:00

I m using XAML written below <Window x:Class=ERP.WinApp.Views.Admin.Patients xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=Patients Height=auto MinWidth=1024 Width=1024

  • 0

I m using XAML written below

<Window x:Class="ERP.WinApp.Views.Admin.Patients"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Patients" Height="auto" MinWidth="1024" Width="1024" ShowInTaskbar="False" Icon="/ERP.WinApp;component/Images/patient.png" WindowStartupLocation="CenterScreen">
    <Grid>
<DataGrid ItemsSource="{Binding}" Grid.Row="1" Name="gridPatients" ></DataGrid>
</Grid>
</Window>

And the Code behind written below

namespace ERP.WinApp.Views.Admin
{
    /// <summary>
    /// Interaction logic for Patients.xaml
    /// </summary>
    public partial class Patients : Window
    {
        public Patients()
        {
            InitializeComponent();

            List<Patient> list = new List<Patient>();
            list = // Populate it through some method
            gridPatients.DataContext = list;
        }

    }
}

Patient class is having few simple properties

public class Patient
    {

        public int Id { get; set; }

        public string FirstName { get; set; }

        public string MiddleName { get; set; }

        public string LastName { get; set; }

        public string FullName { get{ return this.FirstName+ " " +this.MiddleName+ " " +this.LastName; } }

        public DateTime DOB { get; set; }

        public int Age { get { return DateTime.Today.Year - this.DOB.Year; } }

        public char Gender { get; set; }
    }

When I run the app my datagrid is having all columns with data in it while if i want to have few columns only like skipping Id and age and first,middle,last name then what is the best way.

I think doing this is bad way for each column i want to hide

gridPatients.Columns[0].Visibility = Visibility.Collapsed;
  • 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-17T01:40:49+00:00Added an answer on June 17, 2026 at 1:40 am

    You can set AutoGenerateColumns to false, and add required columns.

    <DataGrid ItemsSource="{Binding}" AutoGenerateColumns="False" Grid.Row="1" Name="gridPatients" >
     <ItemTemplate>
       <DataTemplate>
          <DataGridTextColumn Binding={ Path=FirstName}/>
        ... 
        <DataTemplate>
     </ItemTemplate>
    </DataGrid>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Imagine I've got a FlowDocument like so: <FlowDocument xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation ColumnWidth=400 FontSize=14 FontFamily=Georgia Name=document> <Paragraph
I would like to make an application in a one window using XAML. It
Is there a way to launch a new window in WPF using XAML? Or
I have authored some custom classes that I would like to create using XAML:
I'm using this XAML: <Border x:Name=border1 Grid.Row=1> <toolkit:HeaderedContentControl Header=HeaderedContentControl HorizontalContentAlignment=Stretch VerticalContentAlignment=Stretch MaxWidth={Binding ActualWidth, ElementName=border1}
I wish to do this using only XAML - How to add an additional
Is there a way to do 'using' in XAML i.e. declare a namespace and
I want to change content of a Button in XAML using a DataTrigger. Conditionally
I am trying to create a polygon using points in xaml and as per
I'm using this code in a XAML page: <TextBox ItemsSource={Binding Posters, Converter={StaticResource collectionToFirstElementConverter}, Mode=TwoWay}

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.