Coder Social home page Coder Social logo

badcel / bindingsharp Goto Github PK

View Code? Open in Web Editor NEW
12.0 3.0 2.0 139 KB

BindingSharp enables MVVM-Style programming with GTKSharp. It is a library to bind properties of a GTK widget to a viewmodel.

License: GNU Lesser General Public License v2.1

C# 99.92% CSS 0.08%

bindingsharp's Introduction

BindingSharp

Note: As GtkSharp will probably not gain support for INotifyPropertyChanged this project will be rebased on gir.core as it's successor as soon as there are Nuget packages available.

BindingSharp enables MVVM-Style programming with GTKSharp. It is a library to bind properties of a GTK widget to a viewmodel.

If you have a .NET Standard 2.0 or .NET CORE application you can port it's view to GTK and reuse the rest of your code to be deployed on Windows, Linux and MacOs with differnt native UI toolkits.

Features

Using

To use the binding the application must provide the viewmodel to the view to be able to create the binding inside the view.

For a complete sample see the Sample App.

  1. Create a view class with a matching glade file which describes the user interface as XML. Inside your view reference some UI widgets in fields. For working examples see the templates of GtkSharp.

  2. Add the PropertyBindingAttribute or CommandBindingAttribute or ValidationBindingAttribute to a widget of your UI

  3. Call Bind(object obj) in your view's constructor to setup the binding

     public class MyWidget : Box
     {
         ...
    
         [UI]
         [CommandBinding(nameof(ViewModelClass.MyCommand))]
         private Button MyButton;
    
         public MyWidget(object viewmodel) : this(new Builder("MyWidget.glade")) 
         { 
             this.Bind(viewmodel)
         }
    
         ...
     }
    

Building from source


Note

Currently GtkSharp is missing the support for INotifyPropertyChanged on GLib.Object.

There is a pull request to add this feature. Until the pull request is merged you can use a custom version from GtkSharp from my temporary fork.

To compile the code checkout the GTKSharp fork and put it parallel to this repository (see references in *.csproj files)


There are 3 projects inside the repository:

  • BindingSharp: Project source
  • BindingSharp.Sample: Example gtk application
  • BindingSharp.Test: Unit tests

To build the source code run dotnet build in the corresponding project folder.

To run the sample app execute dotnet run in the BindingSharp.Sample folder.

To test the code run dotnet test in the BindingSharp.Test folder.

License

BindingSharp and its related components are licensed under LGPL v2.1 license.

bindingsharp's People

Contributors

badcel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

orion75 bubdm

bindingsharp's Issues

Simplify Attributes

Use only one attribute and detect correct binding code during runtime (ICommand / INotifyPropertyChanged / INotifyDataErrorInfo)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.