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

  • Home
  • SEARCH
  • 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 4053696
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:28:48+00:00 2026-05-20T14:28:48+00:00

I’m experimenting with databinding in WPF I have this datagrid that is bound to

  • 0

I’m experimenting with databinding in WPF

I have this datagrid that is bound to a mysql view, it’s gonna be read only, but I’d like it to automatically refresh when changes are made to the database.
Couldn’t find anything useful on google and I have no idea where to start.

This is the dataprovider class.

class ConDataProvider
{
    private MySqlDataAdapter adapter;
    private Data data;
    private DataTable table;

    public ConDataProvider(string query)
    {
        data = new Data();
        table = new DataTable("con_FullGrid");
        adapter = data.getAdapter(query);
        adapter.Fill(table);
    }
    public DataView GetDView()
    {
            dv = new DataView();
            dv.Table = table;
            return dv;
    }
}

And the XAML for the window

<Window x:Class="HelioWPF_Alpha01.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:local="clr-namespace:HelioWPF_Alpha01"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="676" Width="924" MinHeight="300" MinWidth="463" Background="{x:Null}">
<Window.Resources>
    <ObjectDataProvider x:Key="ConDataProvider" ObjectType="{x:Type local:ConDataProvider}">
        <ObjectDataProvider.ConstructorParameters>
            <sys:String>SELECT * FROM con_FullGrid</sys:String>
        </ObjectDataProvider.ConstructorParameters>
    </ObjectDataProvider>
    <ObjectDataProvider x:Key="btable" ObjectInstance="{StaticResource ConDataProvider}"
                        MethodName="GetDView"/>

</Window.Resources>
<Grid Name="mainGrid" DataContext="{Binding Source={StaticResource btable}" KeyDown="mainGrid_KeyDown" FlowDirection="LeftToRight" >
    <DataGrid AutoGenerateColumns="True" ItemsSource="{Binding}" Name="dataGrid1" FrozenColumnCount="20" RowHeight="25" Grid.ColumnSpan="4" ColumnWidth="*" MouseDoubleClick="dataGrid1_MouseDoubleClick" SelectionMode="Single" Grid.Row="2" Grid.Column="1" TabIndex="1" GotKeyboardFocus="dataGrid1_GotKeyboardFocus">
        <DataGrid.AlternatingRowBackground>
            <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                <GradientStop Color="Black" Offset="0" />
                <GradientStop Color="#16436DF8" Offset="0" />
            </LinearGradientBrush>
        </DataGrid.AlternatingRowBackground></DataGrid>
</Grid>

What I have been doing is kind of faking it by reinitializing the ConDataProvider class in behind code and rebinding the datagrid on various events.
But it’s an ugly hack.
I wouldn’t mind redesigning the whole thing if I have to.

The Data class just contains the connection string and some methods to interact with the database.
You can see it here: http://pastebin.com/m9HLfwEQ

Thanks in advance.
Hope to get some good tips.

  • 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-05-20T14:28:49+00:00Added an answer on May 20, 2026 at 2:28 pm

    How about if you wire up some Reactive Extensions.

    What you could do is create an observable that polls your DB every X seconds. Then have your Observer connect to that observable. In the OnNext event of the Observer, you could add the data to your grid, or rebind, whatever.

    Essentially, you’d be creating something that sits between your database and your app that listens for changes and pushes those changes to you.

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

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
i want to parse a xhtml file and display in UITableView. what is the
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

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.