Archive for the ‘WPF’ Category
Easy way to understand LINQ
There are many videos and tutorials on LINQ. And i am adding one more to the list. I am not going deeply in LINQ but just giving basic syntax understanding of LINQ.
Following is the description of LINQ
from [identifier] in where [boolean expression] order by [[expression](ascending/descending)], [optionally repeat] select [expression] group [expression] by [expression] into [expression]
These LINQ query returns the IEnumerable collection. Let us go line by line into the same.
First line is similar to declaring variable. Here you are declaring variable for your data collection. But this data collection is filter of your source collection. Let’s take one example
var q = from c in contacts
where c.State == "WA"
orderby c.LastName, c.FirstName
select c;
Now, here c is variable and it is subset or equal to contacts. So whenever you have collection from which you want to make queries, first line would be from <Identifier> in <collection>
From next line everybody use expression (Not facial but technical
). This expression must use identifier you have defined in the first line. So in above example, you can see that WHERE and ORDERBY uses c to create expression. c has same members which your source has. Suppose you have contact collection named contacts. And you wrote first line like “from c in contacts” then c contain all the members of contact. Visual studio provide Intellisense using which you can easily create the expression. Where takes boolean expression, while order by take just simple expressions.
Once you have setup the LINQ query, you need to select the collection. It would be simple identifier or may be columns from identifier. One more example for understanding is as follows:
int[] nums = new int[] {0,4,2,6,3,8,3,1};
var result = (from n in nums
where n < 5
orderby n
select n).Distinct();
This is just a very basic understanding on LINQ. But its really vast and if you need to go in bit detail, follow http://www.hookedonlinq.com/MainPage.ashx. Nice website for LINQ
.
Ajax Toolkit – Are you guys using it or not ???
AJAX TOOLKIT for 3.5 is just released. I have seen very much in details the controls which toolkit offers and yes, they are really great piece of controls which aid help is doing quick work professional way.
http://www.asp.net/ajax/ajaxcontroltoolkit/samples/MultiHandleSlider/MultiHandleSlider.aspx (Just look at the sample if you haven’t looked at the same.)
Personally, as i am currently working on CAD/CAM windows based software, I am unaware of most of web technology currently. Recently i read jQuery and next in line is ASP.NET MVC architecture. But I have subscribed many blogs and reading many newsletter, they never discussed or mentioned anything about this toolkit.
Are you guys using it or not ??? Why ???
Free ASP.NET MVC Book From Scott and Rob
a FREE ASP.NET MVC book and a FREE sample website (talked about in that book) that’s also a live working site as opposed to vaporware.
The book is the first 185 pages of a book Rob collaborated on with ScottGu, Scott Hanselman, and Phil Haack. The cool part is that these pages (the free stuff) are all ScottGu’s contribution and are a “0 to 60” summary of getting up to speed with ASP.NET MVC from “File—>New” to dependency injection.
The code is now available up on Codeplex and can be downloaded for all to see!
Link: http://weblogs.asp.net/scottgu/archive/2009/03/10/free-asp-net-mvc-ebook-tutorial.aspx
Also, ASP.NET MVC 1.0 is officially released by Microsoft. So grab it now and learn it
Expression Blend : Conclusion – WPF Tutorial #10
Hope you have visited overview section from 1 to 9. I am skipping other chapters from the UserGuide as I believe once you complete the basic part of Expression, you need to look into the WPF+XAML from the first. And once the WPF is completed or overviewed, you can jump to the remaining expression blend part later. Hope you enjoyed the tutorial. I believe we can continue the same for WPF+XAML section. You can get more on Expression blend on following URL if you need
http://www.microsoft.com/Expression/kc/product.aspx?key=blend
Expression Blend : Transformations – WPF Tutorial #9
This transformation topic only covers the transformation in the view of Expression Blend. There are following simple transformation which you can get in any image manipulation software.
- Reposition
- Resize
- Rotate
- Skew
- Flip
Now, how these transformation applies to the object is depend upon which category of transform you are using. Following is the transformation category:
- RenderTransform The transformation is applied after the layout pass is complete. Using the Selection tool to transform an object on the artboard modifies the RenderTransform properties.
Using the RenderTransform properties is the ideal way to perform transformations on objects because of better application performance.
- LayoutTransform The transformation is applied in memory during layout, before the application is rendered on screen. Use the LayoutTransform properties when you need a parent element to adjust to the transformation applied to a child element.
Following example is taken for Adam Nathan’s book:
This clears the understanding of RenderTransform and LayoutTransform easily. Thanks to Nathan for this.
Last point is cliptobounds property of the control. If that property is true, the control which you transform is clipped into the parents object.
WPF Unleashed! Released – One of Nice book to refer for WPF
I just reviewed different books on WPF. I find Nathan’s WPF unleashed very useful book for learning WPF. You can skip chapter 2 and 3 as that chapters can be boring. You can cover that chapter after going through other chapters.
Just Bring a COPY , read it and finish WPF as soon as possible !!!
StackPanel’s Example
Following is the best example of using StackPanel. It is taken from unleashed. Thanks to Adam Nathan.
<CheckBox Height="18.337" HorizontalAlignment="Left" VerticalAlignment="Top" Width="173.368">
CheckBox
<CheckBox.ToolTip>
<StackPanel>
<Label FontWeight="Bold" Background="Blue" Foreground="White">
The CheckBox
</Label>
<TextBlock Padding="10" TextWrapping="WrapWithOverflow" Width="200">
CheckBox is a familiar control. But in WPF, it’s not much
more than a ToggleButton styled differently!
</TextBlock>
<Line Stroke="Black" StrokeThickness="1" X2="200"/>
<StackPanel Orientation="Horizontal">
<Image Margin="2" />
<Label FontWeight="Bold">Press F1 for more help.</Label>
</StackPanel>
</StackPanel>
</CheckBox.ToolTip>
</CheckBox>
Following is the output of the above code. See the label, TextBlock and line are stacked vertically an Image and Help stacked horizontally. I have removed the image from it as I dont have the same.
It’s the better example of StackPanel.
Expression Blend : Layout – WPF Tutorial #8
From user guide, I skipping the 3D and Media part as it is not as useful at current level. Now, we move on the Layout part of the Expression blend.
Layout is used for laying out different controls on the form. In WPF, they are known as Panels and Containers. Following are panels and container which is used in WPF as layout controls:
Grid contains the row and column for the layout. You can make rows and columns into the grid layout and use same to laying out different control’s which aligned to rows or columns.
Canvas control is similar to old window’s form control. All the control’s resides in canvas has relative X and Y position. It is used for the fix position in the form/page.
In the Dock panel, control’s are always dock to edges defined in the properties.
Stack panel arrange the controls in one line. The middle point of the controls are aligned to either horizontal or vertical defined in properties of stack panel.
Wrap panel is similar to HTML page. It arrange child control from left to right position
When you put controls/shapes/path in the panels, it is displayed as layers drawn. They are numbered in Z-Layer. You can use Bring To Front, Bring to Forward, Send To Back etc function on right click of the control for laying out the controls as you wish.
Expression Blend : Working with Text – WPF Tutorial #7
Hope you are enjoying the Tutorial series of Blend. Please let me know if it needs any improvements.
The next section is covering the Text area of WPF. Until now, we have done how to work with objects (shapes/paths), Drawing shapes/paths and giving appearance to the shapes/path and controls.
Now, agenda of this chapter is to show how to work with the Text controls. The first thing we need to know is which controls are provided in Expression Blend/WPF.
As you are aware with TextBox, RichTextBox, PasswordBox and Label. TextBlock is similar to Label. It provides readonly textblock to user. The only difference between TextBlock and Label is, Label can provide mnemonics support.
FlowDocumentScroll Viewer Provides section which has scrollbar support for that area.
You can edit the appearance same as we have done for shapes/paths.
Formatting Texts : There are many ways for formatting text. Following are the icons which used for the same. Almost all feature may be already used by you working with microsoft office.
There are all the features of text formatting like Font face, size, bold, italic, underline, paragraph, indentation, margins, bulleted or numbered list.
It’s really simple and bery useful though.
Expression Blend : Appearance – WPF Tutorial #6
Hope you liked all previous 5 post. If you directly come to this post, just read the previous posts.
Now, open User Guide that comes with Expression Blend and goto Appearance section. We learned the drawing part that is how to draw and work with different shapes and paths. In this article, we will work on Appearance that is looks of the shapes and controls.
There are different properties by which you can set the looks. Following are list of properties
Fill & Stroke : is used for shape/path and it is for filling the shape or changing border of the same respectively
Background, Foreground & BorderBrush: is similar to Fill and stroke but it is used for the control.
Opacity & Visibility : is for making control/shapes/path transperent.
You can change the values from Properties section. Following are the images…
Similar window is used for editing shapes properties. Following are the different option for brush. There are No Brush, Solid Color Brush, Gradient Brush, Tile Brush. We can use Image Brush and Pattern Brush also. The Brush is sued to set all the above properties.
For Color/Pattern/Brush copy, you can use Eyedropper and Paint Bucket. You can try it from microsoft blend.
Gradient : Gradient brush can be applied to any control/shape. There are linear and radial gradient brush. You can create one shape and use both gradient which is displayed in bottom of gradient brush section. Also to set the Gradient, you can use
.
Bitmap effect: You can use different bitmap effect for making object more attractive.
You can use None, Blur, Glow etc option fo the same. Please put one shape, give gradient color and try all options from it.
huh
