Skip to main content

Posts

Showing posts with the label WPF

Silverlight MVVM

What is MVVM pattern as per wikipedia "The Model View ViewModel (MVVM) is an architectural pattern used in software engineering that originated from Microsoft as a specialization of the Presentation Model design pattern introduced by Martin Fowler.[1] Largely based on the model–view–controller pattern (MVC), MVVM is a specific implementation targeted at UI development platforms which support the event-driven programming in Windows Presentation Foundation (WPF) and Silverlight on the .NET platforms using XAML and .NET languages. Technically different, but similar, Presentation Model design patterns are available in HTML5[2][3] through KnockoutJS, and for Java the ZK framework (Model-View-Binder)." ViewModelBase.csusing System; using System.ComponentModel; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; u…

Draw Fractal tree in wpf

In this post I will show you how to draw Fractal tree in WPF.Before going to implementation details first go throw this link.

Algorithm:To draw a fractal tree is simple:Draw the trunkAt the end of the trunk, split by some angle and draw two branchesRepeat at the end of each branch until a sufficient level of branching is reached


Create a new WPF application and add following code




<Windowx:Class="HelloWorld.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow"Height="350"Width="525">
<Grid>
<ViewboxStretch="Uniform">
<StackPanel>
<StackPanelOrientation="Horizontal"
Margin="5,5,5,0">
<ButtonName="btnStart"Click="btnStart_Click"
Width="50"Content="Start"/>
<TextBlockName="tbLabel"Margin="20,5,0,0"/>
</StackPanel&…

How to draw Sierpinski triangle in WPF

In this post,I will show you how to draw Sierpinski triangle in wpf. Create a new WPF application and add foloowing code in MainWindow.xaml<Windowx:Class="Sierpinski.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"Title="MainWindow"Height="350"Width="525"><Grid><ViewboxStretch="Uniform"><StackPanel><StackPanelOrientation="Horizontal"Margin="5,5,5,0"><ButtonName="btnStart"Click="btnStart_Click"Width="50"Content="Start"/><TextBlockName="tbLabel"Margin="20,5,0,0"/></StackPanel><CanvasName="canvas1"Width="300"Height="300"Margin="5"/></StackPanel></Viewbox></Grid></Window>Open MainWindow.xaml.cs and add following code into itusing System; using S…