Coder Social home page Coder Social logo

bubdm / displaying-xaml Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wongjiahau/displaying-xaml

0.0 0.0 0.0 530 KB

This library is for display the XAML code of theme library for WPF (e.g. MaterialDesignInXamlToolkit)

License: GNU General Public License v3.0

C# 100.00%

displaying-xaml's Introduction

Displaying-XAML

This library is for display the XAML code of theme library for WPF (e.g. MaterialDesignInXamlToolkit/MahApps)

Why is this library written ?

Because the demo app for the theme library I'm using (MaterialDesignInXamlToolkit) is too hard to use.
For example, when I want to use a control in the demo, I have to search through its GitHub repo for the code. Obviously, this is a pain, therefore I wrote this library, so that the code can be displayed besides each control.

Demo

newdemo

How to use this library ?

1. Install from nuget

Install-Package XamlDisplayerPackage -Version 1.0.3

2. Call the XamlDisplayerPanel initializer at the app startup

        private void App_OnStartup(object sender, StartupEventArgs e) {
            XamlDisplayerPanel.Initialize(
                source:
                    XamlDisplayerPanel.SourceEnum.LoadFromLocal ,
                defaultLocalPath:
                    @"C:\Users\User\Source\Repos\Displaying-XAML\XamlDisplayer\Demo\" ,
                defaultRemotePath:
                    "https://raw.githubusercontent.com/wongjiahau/Displaying-XAML/master/XamlDisplayer/Demo/" ,
                attributesToBeRemoved:
                  new List<string>()
                  {
                    "xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"" ,
                    "xmlns:materialDesign=\"http://materialdesigninxaml.net/winfx/xaml/themes\"" ,
                    "xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\""
                  }
            );
        }
  • source determine where you want to load the XAML source file (either from local(your computer) or remote(e.g. GitHub)
  • defaultLocalPath determine where the files shall be loaded by default if you set source as LoadFromLocal
  • defaultRemotePath determine where the files shall be loaded by default if you set source as LoadFromRemote
  • attributesToBeRemoved specifies the attributes that should be filetered out when displaying the code for each control Refer here to learn more about App_OnStartup method

3. At the place where all the pages are hosted (usually MainWindow.xaml), place in the XamlDisplayerHost

<Window x:Class="DisplayXamlDemo.MainWindow">    
        <codeDisplayer:XamlDisplayerHost x:Name="XamlDisplayerHost"/>        
</Window>

The XamlDisplayerHost is actually a Frame, so you can call the Navigate method using it.

4. For each of the page that is going to be navigated, surround all the controls with XamlDisplayerPanel

<UserControl x:Class="XamlDisplayerDemo.Page1">  
    <codeDisplayer:XamlDisplayerPanel>
        <!--All the controls here-->
    </codeDisplayer:XamlDisplayerPanel>                    
</UserControl>     

Note : The XamlDisplayerPanel can be placed on any level of depth

5. Navigate to each pages by calling Navigate method of XamlDisplayerHost

        public MainWindow() {
            InitializeComponent();
            XamlDisplayerHost.Navigate(new Page1());
        }

Actually, you can also use binding to bind its Content, because XamlDisplayerHost is inherited directly from Frame

displaying-xaml's People

Contributors

butchersboy avatar punker76 avatar wongjiahau 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.