Code Monkey home page Code Monkey logo

wpf-autolayout's Introduction

wpf-autolayout

An implementation of Cassowary contraint based system. It contains a Windows WPF control called AutoLayoutPanel that allows you to add controls and define their layout in y=m*x + c model. Where y and x are either the Left, Center, Right, Top, Middle, Bottom, Width and Height property of the control listed previously.

Features

  • Ability to express nearly any layout by describing layout in terms of relationships with math.
  • Support for RTL, LTR auto layouts for localization and cross-lingual interfaces.
  • Incremental solving that's signficantly faster than resolving on each render loop.

API & Example

AutoLayoutPanel panel = new AutoLayoutPanel();
Window.Content = panel;
Button b = new Button();
b.Content = "Button Title";
panel.Children.Add(b);

// Assign the left (X) value to the left panel.
// panel.AddLayoutConstraint(b,"Left",panel,"Left",0,0);

// Vertically and horizontally center:
// panel.AddLayoutConstraint(button, "Middle", "=", panel, "Middle", 1, 0);
// panel.AddLayoutConstraint(button, "Center", "=", panel, "Center", 1, 0);

// Set the width by defining where the left and right values of the button
// should be set.  The button will always have 30 pixel margin on left and right sides.
// panel.AddLayoutConstraint(button, "Left", "=", panel, "Left", 0, 30);
// panel.AddLayoutConstraint(button, "Right", "=", panel, "Right", 0, -30);

API

Dead simple, AutoLayoutPanel inherits from System.Windows.Controls.Panel and adds two new methods:

int AutoLayoutPanel.AddLayoutConstraint(UIElement firstProperty, String firstPropertyName, String equality, UIElement secondProperty, String secondPropertyName, double multiplier, double constant);

Equality can be "=", "<", or ">"

The returned integer is an ID that can be passed back into RemoveLayoutConstraint to remove the constraint.

void AutoLayoutPanel.RemoveLayoutConstraint(int constraintId);

wpf-autolayout's People

Contributors

trevorlinton avatar

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.