Thursday, July 28, 2016

Abstract Class VS Interface in C#

An interface is more supple from the client's perspective:
any class can implement as many interfaces as it wants to. Unfortunately, an interface is more rigid from the developer's perspective: it can't be easily changed and it does not support any kind of reusability.

An abstract class is supple from the developer's perspective:
it supports reusability, it supports encapsulation, it can be extended easily without breaking existing clients.
With all that said, we can conclude the interesting rule of thumb: use abstract classes for building internal APIs and use interfaces for providing external points of extension.

Monday, July 18, 2016

ICommand WPF


<Grid >
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Button Command="{Binding ClickCommand}" Width="100" Height="100" Content="wefwfwef"/>
</Grid>

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        DataContext = new ViewModelBase();
    }
}

public class ViewModelBase
{
    public ViewModelBase()
    {
        _canExecute = true;
    }
    private ICommand _clickCommand;
    public ICommand ClickCommand
    {
        get
        {
            return _clickCommand ?? (_clickCommand = new CommandHandler(() => MyAction(), _canExecute));
        }
    }
    private bool _canExecute;
    public void MyAction()
    {

    }
}
public class CommandHandler : ICommand
{
    private Action _action;
    private bool _canExecute;
    public CommandHandler(Action action, bool canExecute)
    {
        _action = action;
        _canExecute = canExecute;
    }

    public bool CanExecute(object parameter)
    {
        return _canExecute;
    }

    public event EventHandler CanExecuteChanged;

    public void Execute(object parameter)
    {
        _action();
    }
}

Wednesday, July 13, 2016

Triggers in WPF


There are three types of Triggers available.

  • Event Trigger
Event Trigger used perform action when RoutedEvent of FrameworkElement raise.Event Trigger generally used to perform some animation on control (like : colorAnimation, doubleAnumation using KeyFrame etc.)  Let's first understand Storyboard and Animation.

Storyboard Storyboard is used to provide animation to the properties of the UIElement. Storyboard has TargetName andTargetProperty  attached properties for apply animation to the Control (TargetName) and Control Property (TargetProperty).

  • Property Trigger 

Property Trigger Executes Collections of Setters, when UIElements property value changes. To create a trigger on any controls, you have to set trigger in style of the control.


MultiTrigger MultiTrigger is used to set action on Multiple Property change. It will execute when all condition are satisfy within MulitTrigger.Condition.

 

  • Data Trigger        

 As the name suggest, DataTrigger applies property value to perform action on Data that Binding to the UIElement. DataTrigger allows to set property value when Binding Data matches specified condition.


MultiDataTrigger MultiDataTrigger is same as DataTrigger in addition property value applied on multiple condition is matches.

 

Ref this link for more details

http://www.codeproject.com/Tips/522041/Triggers-in-WPF

Tuesday, May 24, 2016

MongoDB

MongoDB (from humongous) is a free and open-source cross-platform document-oriented database. Classified as a NoSQL database, MongoDB avoids the traditional table-based relational database structure in favor of JSON-like documents with dynamic schemas (MongoDB calls the format BSON), making the integration of data in certain types of applications easier and faster. Developed by MongoDB Inc, this tool is free and open-source. As of July 2015, MongoDB is the fourth most popular type of database management system, and the most popular for document stores.

Monday, May 23, 2016

partial (Method)

A partial method has its signature defined in one part of a partial type, and its implementation defined in another part of the type. Partial methods enable class designers to provide method hooks, similar to event handlers, that developers may decide to implement or not. If the developer does not supply an implementation, the compiler removes the signature at compile time. The following conditions apply to partial methods:

  • Signatures in both parts of the partial type must match.

  • The method must return void.

  • No access modifiers are allowed. Partial methods are implicitly private.

namespace PM  {      partial class A      {          partial void OnSomethingHappened(string s);      }        // This part can be in a separate file.       partial class A      {          // Comment out this method and the program           // will still compile.           partial void OnSomethingHappened(String s)          {              Console.WriteLine("Something happened: {0}", s);          }      }  }

Saturday, May 21, 2016

Database Answer

Database diagram for all modules available in this link 



--
With Regards-
Siddu 

Please consider the environment before printing this e-mail

Wednesday, May 18, 2016

Filter an ObservableCollection with a CollectionView in C#

Article regarding how to apply filter condition on Observable Collection

http://jacobmsaylor.com/?p=1270

Code Formater

Paste Here Your Source Code
Source Code Formatting Options
1) Convert Tab into Space :
2) Need Line Code Numbering :
3) Remove blank lines :
4) Embeded styles / Stylesheet :
5) Code Block Width :
6) Code Block Height :
7) Alternative Background :
Copy Formatted Source Code
 
Preview Of Formatted Code