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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:58:20+00:00 2026-06-10T02:58:20+00:00

I am quite new to wpf so maybe I am missing something obvious here.

  • 0

I am quite new to wpf so maybe I am missing something obvious here. I have found a similar question in stackoverflow and tried the solution (which is implemented in the code given below) but was not able to get it work. The link is here. Let me explain the problem. I am working with framework 2010.

I have a usercontrol which contains 1 datagrid and 3 buttons. The xaml of the same is as below.

<UserControl x:Class="RadarControls.RadarDataGrid"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:diagnostics="clr-namespace:System.Diagnostics;assembly=WindowsBase"
         xmlns:local="clr-namespace:RadarControls"
         mc:Ignorable="d" 
         d:DesignHeight="300" d:DesignWidth="300">
<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition />
        <ColumnDefinition />
        <ColumnDefinition />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition Height="25" />
    </Grid.RowDefinitions>

    <DataGrid Name="myGrid" Grid.ColumnSpan="3" ItemsSource="{Binding}" AutoGenerateColumns="True"></DataGrid>

    <Button Content="Add" Grid.Row="1" Height="23" Margin="0,2,2,0" HorizontalAlignment="Left" Name="btnAdd" Width="100" />
    <Button Content="Delete" Grid.Column="1" Grid.Row="1" Margin="0,2,2,0" Height="23" HorizontalAlignment="Left" Name="btnDelete" Width="100" />
    <Button Content="Save" Grid.Column="2" Grid.Row="1" Height="23" Margin="0,2,0,0" HorizontalAlignment="Left" Name="btnSave" Width="100" />
</Grid>
</UserControl>

The xaml of my window where i am using this usercontrol is as below

<Window x:Class="RadarStudio.Users"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ctrls="clr-namespace:RadarControls;assembly=RadarControls"
    xmlns:vm='clr-namespace:RadarViewModel.Users;assembly=RadarViewModel'
    Title="Users" Height="300" Width="300">
<Grid >
    <ctrls:RadarDataGrid Name="grid1" DataContext="{Binding str}"></ctrls:RadarDataGrid>
</Grid>

My window code behind is as follows

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Collections.ObjectModel;

namespace RadarStudio
{
    /// <summary>
    /// Interaction logic for Users.xaml
    /// </summary>
    public partial class Users : Window
    {
        public Users()
        {
            InitializeComponent();
            //this.DataContext = this;

            str.Add("dhaval");
            str.Add("ravinder");
        }

        public ObservableCollection<string> str = new ObservableCollection<string>();
    }
}

I tried so many things but I am not able to get the strings on my grid.

Please help!
Thanks in advance!

Regards,

Samar

  • 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-10T02:58:22+00:00Added an answer on June 10, 2026 at 2:58 am

    This seems to be a silly mistake but when I initialized the observable collection before InitializeComponent call then it started to show the data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am quite new to WPF.I came accross this wonderful project . I have
Sorry for the possible noob question, I'm quite new to C# and WPF. I
I have problem with WPF - I'm quiet new in this smart technology. So
Quite new to maven here so let me explain first what I am trying
I am quite new to mongoid and rails. So I have some troubles to
I must say I am quite new at WPF. I am building my first
Hi all i need help wih my combobox. Iam quite new in the WPF
I am relatively new to WPF, and some things with it are quite foreign
I'm quite new to WPF and as new to Caliburn.Micro. What I'm trying to
I'm very new to MVC...I have quite a bit of knowledge with Silver-light and

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.