Understanding of Association, Aggregation and compostion.
Understanding of Association, Aggregation and compostion
http://www.codeproject.com/Articles/330447/Understanding-Association-Aggregation-and-Composit

if i look back, i am lost
tumblr dot com
đȘŒ
Acquired Stardust

PR's Tumblrdome

Discoholic đȘ©
let's talk about Bridgerton tea, my ask is open
Aqua Utopiaïœæ”·ăźćșă§èšæ¶ă玥ă
wallacepolsom
No title available
ojovivo
$LAYYYTER

oozey mess
PUT YOUR BEARD IN MY MOUTH

tannertan36
Cosimo Galluzzi
DEAR READER

â

@theartofmadeline
occasionally subtle
seen from Canada

seen from France

seen from United States
seen from United States
seen from Canada

seen from Chile

seen from Malaysia

seen from United States
seen from United States

seen from United States

seen from TĂŒrkiye

seen from Malaysia

seen from Malaysia

seen from Canada
seen from United States
seen from Malaysia
seen from CĂŽte dâIvoire
seen from United States
seen from Indonesia
seen from United States
@hsiddu
Understanding of Association, Aggregation and compostion.
Understanding of Association, Aggregation and compostion
http://www.codeproject.com/Articles/330447/Understanding-Association-Aggregation-and-Composit
Thread Pool - BackgroundWorker
BackgroundWorker is a helper class in theSystem.ComponentModel namespace for managing a worker thread. It can be considered a general-purpose implementation of the EAP, and provides the following features:
A cooperative cancellation model
The ability to safely update WPF or Windows Forms controlswhen the worker completes
Forwarding of exceptions to the completion event
A protocol for reporting progress
An implementation of IComponent allowing it to be sited in Visual Studioâs designer
BackgroundWorker uses the thread pool, which means you should never call Abort on a BackgroundWorker thread.
Using BackgroundWorker
Here are the minimum steps in using BackgroundWorker:
Instantiate BackgroundWorker and handle the DoWork event.
Call RunWorkerAsync, optionally with an object argument.
This then sets it in motion. Any argument passed toRunWorkerAsync will be forwarded to DoWorkâs event handler, via the event argumentâs Argument property. Hereâs an example:
class Program {  static BackgroundWorker _bw = new BackgroundWorker();  static void Main()  {    _bw.DoWork += bw_DoWork;    _bw.RunWorkerAsync ("Message to worker");    Console.ReadLine();  }  static void bw_DoWork (object sender, DoWorkEventArgs e)  {    // This is called on the worker thread    Console.WriteLine (e.Argument);       // writes "Message to worker"    // Perform time-consuming task...  } }
BackgroundWorker has a RunWorkerCompleted event that fires after the DoWork event handler has done its job. Handling RunWorkerCompleted is not mandatory, but you usually do so in order to query any exception that was thrown in DoWork. Further, code within a RunWorkerCompleted event handler is able to update user interface controls without explicit marshaling; code within the DoWork event handler cannot.
To add support for progress reporting:
Set the WorkerReportsProgress property to true.
Periodically call ReportProgress from within the DoWork event handler with a âpercentage completeâ value, and optionally, a user-state object.
Handle the ProgressChanged event, querying its event argumentâs ProgressPercentage property.
Code in the ProgressChanged event handler is free to interact with UI controls just as withRunWorkerCompleted. This is typically where you will update a progress bar.
To add support for cancellation:
Set the WorkerSupportsCancellation property to true.
Periodically check the CancellationPending property from within the DoWork event handler. If itâs true, set the event argumentâs Cancel property to true, and return. (The worker can also set Cancel and exit withoutCancellationPending being true if it decides that the job is too difficult and it canât go on.)
Call CancelAsync to request cancellation.
Hereâs an example that implements all the preceding features:
using System; using System.Threading; using System.ComponentModel; class Program {  static BackgroundWorker _bw;  static void Main()  {    _bw = new BackgroundWorker    {      WorkerReportsProgress = true,      WorkerSupportsCancellation = true    };    _bw.DoWork += bw_DoWork;    _bw.ProgressChanged += bw_ProgressChanged;    _bw.RunWorkerCompleted += bw_RunWorkerCompleted;    _bw.RunWorkerAsync ("Hello to worker");    Console.WriteLine ("Press Enter in the next 5 seconds to cancel");    Console.ReadLine();    if (_bw.IsBusy) _bw.CancelAsync();    Console.ReadLine();  }  static void bw_DoWork (object sender, DoWorkEventArgs e)  {    for (int i = 0; i <= 100; i += 20)    {      if (_bw.CancellationPending) { e.Cancel = true; return; }      _bw.ReportProgress (i);      Thread.Sleep (1000);     // Just for the demo... don't go sleeping    }                          // for real in pooled threads!    e.Result = 123;   // This gets passed to RunWorkerCompleted  }  static void bw_RunWorkerCompleted (object sender,                                     RunWorkerCompletedEventArgs e)  {    if (e.Cancelled)      Console.WriteLine ("You canceled!");    else if (e.Error != null)      Console.WriteLine ("Worker exception: " + e.Error.ToString());    else      Console.WriteLine ("Complete: " + e.Result);     // from DoWork  }  static void bw_ProgressChanged (object sender,                                  ProgressChangedEventArgs e)  {    Console.WriteLine ("Reached " + e.ProgressPercentage + "%");  } }
Press Enter in the next 5 seconds to cancel Reached 0% Reached 20% Reached 40% Reached 60% Reached 80% Reached 100% Complete: 123 Press Enter in the next 5 seconds to cancel Reached 0% Reached 20% Reached 40% You canceled!
Subclassing BackgroundWorker
BackgroundWorker is not sealed and provides a virtual OnDoWork method, suggesting another pattern for its use. In writing a potentially long-running method, you could write an additional version returning a subclassedBackgroundWorker, preconfigured to perform the job concurrently. The consumer then needs to handle only theRunWorkerCompleted and ProgressChanged events. For instance, suppose we wrote a time-consuming method called GetFinancialTotals:
public class Client { Â Dictionary <string,int> GetFinancialTotals (int foo, int bar) { ... } Â ... }
We could refactor it as follows:
public class Client {  public FinancialWorker GetFinancialTotalsBackground (int foo, int bar)  {    return new FinancialWorker (foo, bar);  } } public class FinancialWorker : BackgroundWorker {  public Dictionary <string,int> Result;  // You can add typed fields.  public readonly int Foo, Bar;  public FinancialWorker()  {    WorkerReportsProgress = true;    WorkerSupportsCancellation = true;  }  public FinancialWorker (int foo, int bar) : this()  {    this.Foo = foo; this.Bar = bar;  }  protected override void OnDoWork (DoWorkEventArgs e)  {    ReportProgress (0, "Working hard on this report...");    // Initialize financial report data    // ...    while (!<finished report>)    {      if (CancellationPending) { e.Cancel = true; return; }      // Perform another calculation step ...      // ...      ReportProgress (percentCompleteCalc, "Getting there...");    }    ReportProgress (100, "Done!");    e.Result = Result = <completed report data>;  } }
Whoever calls GetFinancialTotalsBackground then gets a FinancialWorker: a wrapper to manage the background operation with real-world usability. It can report progress, can be canceled, is friendly with WPF and Windows Forms applications, and handles exceptions well.
BackgroundWorker and ProgressBar demo
public partial class Form1 : Form { public Form1() { InitializeComponent(); Shown += new EventHandler(Form1_Shown); // To report progress from the background worker we need to set this property backgroundWorker1.WorkerReportsProgress = true; // This event will be raised on the worker thread when the worker starts backgroundWorker1.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork); // This event will be raised when we call ReportProgress backgroundWorker1.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker1_ProgressChanged); } void Form1_Shown(object sender, EventArgs e) { // Start the background worker backgroundWorker1.RunWorkerAsync(); } // On worker thread so do our thing! void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { // Your background task goes here for (int i = 0; i <= 100; i++) { // Report progress to 'UI' thread backgroundWorker1.ReportProgress(i); // Simulate long task System.Threading.Thread.Sleep(100); } } // Back on the 'UI' thread so we can update the progress bar void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e) { // The progress percentage is a property of e progressBar1.Value = e.ProgressPercentage; } }
Events and Delegates
Events and Delegates
class Program { static void Main(string[] args) { Ball ball = new Ball(); BallEventArgs balEvt = new BallEventArgs(10, 10); Pitcher pi = new Pitcher(ball); ball.OnBallInPlay(balEvt); } }
//Delegate:
public class Ball { public delegate void eventDelegate(object o,EventArgs e); public event eventDelegate BallInPlay; public void OnBallInPlay(BallEventArgs e) { eventDelegate ballInPlay = BallInPlay; if (ballInPlay != null) ballInPlay(this, e); } } public class BallEventArgs:EventArgs{ public int Distance { get; private set; } public int Trajectory { get; private set; } public BallEventArgs(int trajectory, int distance) { this.Trajectory = trajectory; this.Distance = distance; } } class Pitcher { public Pitcher(Ball ball) { ball.BallInPlay += new Ball.eventDelegate(ball_BallInPlay); } void ball_BallInPlay(object sender, EventArgs e) { if (e is BallEventArgs) { BallEventArgs ballEventArgs = e as BallEventArgs; if ((ballEventArgs.Distance < 95) && (ballEventArgs.Trajectory < 60)) CatchBall(); else CoverFirstBase(); } } private void CatchBall() { Console.WriteLine("Pitcher: I caught the ball"); } private void CoverFirstBase() { Console.WriteLine("Pitcher: I covered first base"); } }
//EventHandler :
public class Ball { public event EventHandler BallInPlay; public void OnBallInPlay(BallEventArgs e) { EventHandler ballInPlay = BallInPlay; if (ballInPlay != null) ballInPlay(this, e); } } public class BallEventArgs:EventArgs{ public int Distance { get; private set; } public int Trajectory { get; private set; } public BallEventArgs(int trajectory, int distance) { this.Trajectory = trajectory; this.Distance = distance; } } class Pitcher { public Pitcher(Ball ball) { ball.BallInPlay += new EventHandler(ball_BallInPlay); } void ball_BallInPlay(object sender, EventArgs e) { if (e is BallEventArgs) { BallEventArgs ballEventArgs = e as BallEventArgs; if ((ballEventArgs.Distance < 95) && (ballEventArgs.Trajectory < 60)) CatchBall(); else CoverFirstBase(); } } private void CatchBall() { Console.WriteLine("Pitcher: I caught the ball"); } private void CoverFirstBase() { Console.WriteLine("Pitcher: I covered first base"); } }
ThreadPool - Asynchronous delegates
ThreadPool - Asynchronous delegates
ThreadPool.QueueUserWorkItem doesnât provide an easy mechanism for getting return values back from a thread after it has finished executing. Asynchronous delegate invocations (asynchronous delegates for short) solve this, allowing any number of typed arguments to be passed in both directions. Furthermore, unhandled exceptions on asynchronous delegates are conveniently rethrown on the original thread (or more accurately, the thread that callsEndInvoke), and so they donât need explicit handling.
Hereâs how you start a worker task via an asynchronous delegate:
Instantiate a delegate targeting the method you want to run in parallel (typically one of the predefined Funcdelegates).
Call BeginInvoke on the delegate, saving its IAsyncResult return value. BeginInvoke returns immediately to the caller. You can then perform other activities while the pooled thread is working.
When you need the results, call EndInvoke on the delegate, passing in the saved IAsyncResult object.
In the following example, we use an asynchronous delegate invocation to execute concurrently with the main thread, a simple method that returns a stringâs length:
static void Main() { Â Func method = Work; Â IAsyncResult cookie = method.BeginInvoke ("test", null, null); Â // Â // ... here's where we can do other work in parallel... Â // Â int result = method.EndInvoke (cookie); Â Console.WriteLine ("String length is: " + result); } static int Work (string s) { return s.Length; }
EndInvoke does three things. First, it waits for the asynchronous delegate to finish executing, if it hasnât already. Second, it receives the return value (as well as any ref or out parameters). Third, it throws any unhandled worker exception back to the calling thread.
ThreadPool - QueueUserWorkItem
ThreadPool.QueueUserWorkItem
You can't use the Task Parallel Library if you're targeting an earlier version of the .NET Framework (prior to 4.0). Instead, you must use one of the older constructs for entering the thread pool: ThreadPool.QueueUserWorkItem and asynchronous delegates. The difference between the two is that asynchronous delegates let you return data from the thread. Asynchronous delegates also marshal any exception back to the caller.
QueueUserWorkItem
To use QueueUserWorkItem, simply call this method with a delegate that you want to run on a pooled thread:
static void Main() { Â ThreadPool.QueueUserWorkItem (Go); Â ThreadPool.QueueUserWorkItem (Go, 123); Â Console.ReadLine(); } static void Go (object data)Â Â // data will be null with the first call. { Â Console.WriteLine ("Hello from the thread pool! " + data); }
Our target method, Go, must accept a single object argument (to satisfy the WaitCallback delegate). This provides a convenient way of passing data to the method, just like with ParameterizedThreadStart. Unlike with Task,QueueUserWorkItem doesn't return an object to help you subsequently manage execution.Â
We must use WaitCallback. At MSDN, WaitCallback is described as a delegate callback method to be called when the ThreadPool executes. It is a delegate that "calls back" its argument. WaitCallback You can use WaitCallback by simply specifying the "new WaitCallback" syntax as the first argument to ThreadPool.QueueUserWorkItem. You don't need any other code to make this approach effective.
public partial class MainWindow : Form { // This is the delegate that runs on the UI thread to update the bar. public delegate void BarDelegate(); // The form's constructor (autogenerated by Visual Studio) public MainWindow() { InitializeComponent(); } // When a buttom is pressed, launch a new thread private void button_Click(object sender, EventArgs e) { // Set progress bar length. progressBar1.Maximum = 6; progressBar1.Minimum = 0; // Pass these values to the thread. ThreadInfo threadInfo = new ThreadInfo(); threadInfo.FileName = "file.txt"; threadInfo.SelectedIndex = 3; ThreadPool.QueueUserWorkItem(new WaitCallback(ProcessFile), threadInfo); } // What runs on a background thread. private void ProcessFile(object a) { // (Omitted) // Do something important using 'a'. // Tell the UI we are done. try { // Invoke the delegate on the form. this.Invoke(new BarDelegate(UpdateBar)); } catch { // Some problem occurred but we can recover. } } // Update the graphical bar. private void UpdateBar() { progressBar1.Value++; if (progressBar1.Value == progressBar1.Maximum) { // We are finished and the progress bar is full. } } }
Source
http://www.albahari.com/threading/#_Thread_Pooling
http://www.dotnetperls.com/threadpool
When & why to use delegates?
Say you want to write a procedure to integrate some real-valued function f (x) over some interval [a, b]. Say we want to use the 3-Point Gaussian method to do this (any will do, of course). Ideally we want some function that looks like:
// 'f' is the integrand we want to integrate over [a, b] with 'n' subintervals. static double Gauss3(Integrand f, double a, double b, int n) { double res = 0; // compute result // ... return res; }
So we can pass in any Integrand, f, and get its definite integral over the closed interval. Just what type should Integrand be? Without Delegates Well, without delegates, we'd need some sort of interface with a single method, say eval declared as follows:
// Interface describing real-valued functions of one variable. interface Integrand { double eval(double x); }
Then we'd need to create a whole bunch of classes implementing this interface, as follows:
// Some function class MyFunc1 : Integrand { public double eval(double x) { return /* some_result */ ; } }
// Some other function class MyFunc2 : Integrand { public double eval(double x) { return /* some_result */ ; } } // etc
Then to use them in our Gauss3 method, we need to invoke it as follows:
double res1 = Gauss3(new MyFunc1(), -1, 1, 16); double res2 = Gauss3(new MyFunc2(), 0, Math.PI, 16);
And Gauss3 needs to do the look like the following:
static double Gauss3(Integrand f, double a, double b, int n) { // Use the integrand passed in: f.eval(x); }
So we need to do all that just to use our arbitrary functions in Guass3. With Delegates public delegate double Integrand(double x); Now we can define some static (or not) functions adhering to that prototype:
class Program { static double MyFunc1(double x) { /* ... */ } static double MyFunc2(double x) { /* ... */ } // ... etc ... public static double Gauss3(Integrand f, ...) { // Now just call the function naturally, no f.eval() stuff. double a = f(x); // ... } // Let's use it static void Main() { // Just pass the function in naturally (well, its reference). double res = Gauss3(MyFunc1, a, b, n); double res = Gauss3(MyFunc2, a, b, n); } }
No interfaces, no clunky .eval stuff, no object instantiate, just simple function-pointer like usage, for a simple task. Of course, delegates are more than just function pointers under the hood, but that's a separate issue (function chaining and events). source:Â http://stackoverflow.com/questions/2019402/when-why-to-use-delegates
Differences between Abstract Factory Pattern and Factory Method
Factory Method is used to create one product only but Abstract Factory is about creating families of related or dependent products.
Factory Method pattern exposes a method to the client for creating the object whereas in case ofAbstract Factory they expose a family of related objects which may consist of these Factory methods.
Factory Method pattern hides the construction of single object where as Abstract factory method hides the construction of a family of related objects. Abstract factories are usually implemented using (a set of) factory methods.
AbstractFactory pattern uses composition to delegate responsibility of creating object to another class while Factory design pattern uses inheritance and relies on derived class or sub class to create object.
The idea behind the Factory Method pattern is that it allows for the case where a client doesn't know what concrete classes it will be required to create at runtime, but just wants to get a class that will do the job while AbstractFactory pattern is best utilised when your system has to create multiple families of products or you want to provide a library of products without exposing the implementation details.!
Factory Pattern Implementation:Â
AbstractFactory Pattern Implementation:
WPF Questions
1. What is WPF? WPF is the latest presentation API by Microsoft Windows. It is 2D and 3D graphic engine. Its capabilities include:- All the common user controls. For example, check boxes, buttons, sliders etc. Supports flow and fix format documents all the functionality of Flash and HTML Data binding Multimedia Animation 2. What are the types of documents supported by WPF? Two types of the documents supported by Windows Presentation Foundation (WPF) are the Flow format and fixed Format document. Flow format document alters the content to fit the screen size while fixed format document present content irrespective of the screen size. 3. Name the namespace required for working with 3D. The namespace required for working in 3D is System.Windows.Media.Medi3D. 4. Is it right to say that WPF has replaced DirectX? No, WPF can never replace DirectX. WPF cannot be used to create games with stunning graphics. WPF is meant to be a replacement for windows form, not DirectX. 5. What are dependency properties? Properties that belong to a specific class but can be used for another are called the dependency properties. 6. How can the size of StatusBar be increased proportionally? By overruling the ItemsPanel attribute of StatusBar with a grid. The gridâs columns can be appropriately configured to get the desired result. 7. What are Freezable objects in WPF? An object, which has its state locked down, so that it becomes unchangeable, is known as a freezable object. Such objects perform better. It is also safer if they are required to be shared between threads. 8. Why should WPF be preferred over Adobe Flash? WPF is a more recent technology and thus has the latest development tools. It supports a broader range of programming languages and has a robust control reuse. Â 9. How is Silverlight different from WPF browser application? One of the major differences is that .NET framework is required for running WPF browser applications on the client machine. But Silverlight runs using only the plug-in. Another point of difference is that applications made in WPF depend on the OS as .NET Framework only runs on Windows. On the other hand, the Silverlight plug-in can be installed on those OSs also, which are not Windows. 10. Name the methods present in the DependencyObject. It has three objects, namely: SetValue ClearValue GetValue 11. Write about PRISM. PRISM is a framework for creating complex applications for WPF, Silverlight or Windows Phone. PRISM utilizes MVVM, IC, Command Patterns, DI and Separation of Concerns to get loose coupling. 12. Is it possible to use Windows Forms in a WPF application? Yes, Windows form can be used in WPF. Windows form can appear as a WPF pop. The controls of this Window form can be placed besides WPF controls in a WPF page by utilizing the functions of the WindowsFormsHost control that comes preinstalled. 13. Describe CustomControl briefly. CustomControl widens the functions of existing controls. It consists of a default style in Themes/Generic.xaml and a code file. It is the best way to make a control library and can also be styled or templated. Â 14. Name the common assemblies used in WPF? PresentationFoundation WindowsBase PresentaionCore 15. Define Path animations in WPF Path animation is a type of animation in which the animated object follows a path set by the Path geometry. 16. Can WPF applications be made without XAML? Yes WPF applications can be created without XAML as using XAML in WPF is a matter of choice. Â 17. What are the types of windows in WPF? WPF has three types of windows: Normal Window Page Window Navigate Window 18. How can elements in a ListBox be sorted? Sorting can be done by using a property of the ItemsCollection object. ItemsCollection contains an attribute, SortDescriptions, which holds System.ComponentModel.SortDescription instances. Every SortDescription instance defines how the elements should be sorted and indicates if the sort is descending or ascending. For instance, this code sorts elements of ContentControl on the basis of their word count property: myItemsControl.Items.SortDescriptions.Add(new SortDescription(âWordCountâ, ListSortDirection.Descending)); 19. How is MVVM different from MVC? MVC stands for Model-View Controller and.MVVM stands for Model-View ViewModel. In MVVM, View Model is used instead of a controller. This View Model is present beneath the UI layer. It reveals the command objects and data that the view requires. It acts like a container object from which view gets its actions and data. 20. Explain Routed events in WPF. An event, which can invoke handlers on more than one listeners present in an element tree, instead of the single object which called the event, is known as a Routed event. 21. How is System.Windows.Media.Visual dll utilized in WPF? It is used whenever a requirement for creating custom user interface arises. It is a drawing object, which gives instructions for making an object. These instructions include opacity etc. of the drawing. The Visual class also bridges the functionalities of WPF managed classes and the MilCore.dll. 22. What are the various layout panels in WPF? They are: Stack Panel Grid Panel Canvas Panel Dock Panel Wrap Panel 23. Name the important subsystems in WPF The major subsystems are: Windows.Controls.Control Windows.DependancyObject Windows.FrameworkElement Windows.Media.Visuals Object Threading.DispatcherObject Windows.UIElements 24. What does BAML mean in WPF? BAML is the abbreviation for Binary Application Markup Language. It is nothing but XAML that has been tokenized, parsed and changed into binary form. BAML is a compressed declarative language, which gets loaded and parsed quicker than XAML. Â 25. What is Difference between Page and Window Controls in WPF? The basic difference is that Window Control presides over Windows Application while Page Control presides over the hosted Browser Applications. Also, Window control may contain Page Control, but the reverse cannot happen. 26. What are Attached Properties in WPF? Attached properties are basically Dependency Properties that allows the attachment of a value to any random object. 27. What is the INotifyPropertyChanged Interface? The InotifyPropertyChanged notifies clients, generally those who are binding, if the value of a property gets changed. It has an event, called PropertyChanged, which gets raised everytime a property of Model object is changed. 28. What is the basic difference between Events and Commands in the MVVM Model? Commands are more powerful and are advantageous to use instead of events. Actions are deeply connected with the eventâs source and, therefore, the events cannot be reused easily. But commands make it possible to efficiently maintain multiple actions at one place and then reuse them as per our requirement. 29. What is the method to force close a ToolTip, which is currently visible? It can be closed by setting the tooltipâs IsOpen property to false. 30. Write the differences between DynamicResource and StaticResource. The most basic difference is that StaticResource evaluates the resource one time only, but DynamicResource evaluates it every time the resource is required. And due to this reason, DyanamicResource is heavy on the system but it makes pages or windows load faster 31. Explain MVVM pattern. MVVM pattern divides the UI code into 3 basic parts: Model â It represents a set of classes, which contain data received from databases. View â It is the code that agrees with the visual representation of the data. ViewModel â It is the layer that binds View and Model together. It presents this data in a manner, which is easy to understand. It also controls how View interacts with the application. 32. Why are layout panels needed for in WPF? Layout Panels are needed so that the controls fit screens of different sizes or having different font sizes. If we arrange controls on fixed pixel coordinates, then this model will fail when moved to a different environment. For this reason, Layout panels are necessary. 33. Write about UserControl in brief. UserControl wraps existing controls into a single reusable group. It contains a XAML file and a code. UserControl cannot be styled or templated. 34. What is the way to determine if a Freezable object is Frozen? âIsFrozenâ property of the object can be used to determine if the freezable object is frozen. 35. What is the unit of measurement in WPF? All measurements are made in device-independent pixels, or logical pixels. One pixel is 1/96th part of an inch. These logical pixels are always mentioned as double, this enables them to have a fractional value too. 36. What is an adorner? They are a special kind of FrameworkElement that provide visual clues to the user. They are also used to add handles to elements and give information about the state of a control. Adorners are bound to the UIElement and are rendered on a surface that lies above the element, which is adorned. This surface is called an AdornerLayer. Adorners are mostly placed relatively to the bounded element. 37. Explain Serialization? It is the process of converting the state of an object to stream of bytes. 38. Is MDI supported in WPF? MDI is not supported in WPF. UserControl can be used to give the same functionality as MDI. 39. What is XBAP? XBAP is the abbreviated form of XAML Browser Application. It allows WPF applications to run inside web browsers. Installation of .NET framework on the client machine is a prerequisite for running WPF applications. But hosted applications are not given full admission to the clientâs machine and are executed in a sandbox environment. Using WPF, such applications can also be created, which run directly in the browser. These applications are called XBAP. 40. In what sense are WPF and Silverlight similar? Silverlight and WPF are similar in the sense that they both use XAML and share the same code, syntax and libraries. 41. How to make a ToolTip appear while hovering over a disabled element? For this purpose, the ShowOnDisabled property can be used. It belongs to the ToolTipService class. 42. How can ListBox be made to scroll smoothly? ListBox is configured to scroll on an item-by-item basis by default. This is dependent on the height of each element and the scrolling action, thus, giving a rough feeling. Better way is to configure scrolling action so that it shifts items by a few pixels irrespective of their height. This is done by setting the ScrollViewer.CanContentScroll property to âfalseâ. This will, however, make the ListBox lose the virtualization property. 43. Where does the execution start in a WPF application? WPF applications created in Visual Studio run without a Main method. This is because the applications are special-cased when they are compiled from XAML. That means, Visual Studio attaches a Build Action of ApplicationDefinition to the XAML file. This results in the auto generation of a Main method. 44. Can Windows Service be created Using WPF? No, Windows Services cannot be created using WPF. WPF is a presentation language. Windows services need specific permissions to execute some GUI related functions. Therefore, if it does not get the required permissions, it gives errors. 45. What are the different kinds of Routed events in WPF? There are three types of Routed events in WPF. They are: Direct â This event can only be raised by the element in which it was originated. Tunneling â This event is first raised by the element in which it was originated and then it gets raised by each consecutive container in the visual tree. Bubbling â This event is first raised by the uppermost container in the visual tree and then gets raised by each consecutive container lying below the uppermost one, till it reaches the element it where it was originated. 46. Why is it better to wrap items in ComboBoxItem? It has some important properties like IsSelected and IsHighlighted and also some necessary events like Selected and Unselected. ComboBoxItem is a content control and is thus very useful for adding simple strings to a ComboBox. Â 47. How to get Automation IDs of items in a ItemsControl? The best way to do this is by setting it Name property as it is utilized for automation purposes by default. But if you require to give an ID to an element, other than itâs name, then the AutomationProperties.AutomationID property can be set as per need. Â 48. How can command-line arguments be retrieved in a WPF application? The most preferred method for this is to call System.Environment.GetCommandLineArgs at any random point in the application. 49. State the name of the classes, which contain arbitrary content. Content Control HeaderedContent Control Items Control HeaderedItems Control 50. Which NameSpace has âPopupâ and âThumbâ controls? The namespace system.windows.controls.primitives has âPopupâ and âThumbâ controls.
When facing a tough decision, flip a coin, not to decide for you, but because youâll realize what you really want while itâs in the air.
Best Life Hacks
The Best Life Hacks of 2013