brilliant. Finally, I felt a little bit about XAML.
Next we will talk about the technology of multiple grid sharing width groups. Smaple refers to putting the grid into the scrollviewer, but once the scollbar is rolled, the title of the grid will be rolled together. In order to make the title remain unchanged, two grids should be created: one with the title; the other is placed in the body and nested in scrollviewer. In this way, the rolling problem is solved, and another problem occurs again
1. Reference weifenluo. winformsui. Docking. dll
2. Add the dockpanel control to the main form and set the dock to fill.
3. Create a new form to inherit from weifenluo. winformsui. Docking. dockcontent
4. input the dockpanel and position of the main form in the show parameter of the instantiated form.Form2 FRM =
NewForm2 ();
FRM. Show (
This. Dockpanel1, weifenluo. winformsui. Docking. dockstate. dock
enumeration. You can also use horizontalalignment and verticalignment for alignment.
3. Canvas
It is easy to understand and use canvas. Left and canvas. Top to locate the absolute point of X-axis and Y-axis.
4. dockpanel
Dockpanel uses the dock attribute to locate dockpanel. the left, top, right, and bottom values can be set in the dock enumeration
multiple elements, such as text boxes, buttons.Core Layout Panel
Name
Description
StackPanel
Place elements in a horizontal or vertical stack.
WrapPanel
Places an element in a series of lines that can be wrapped.
DockPanel
Adjusts elements based on the bounds of the entire container.
Grid
Multi-row and multi-column emission elements for the wi
; dockPanel in the Toolkit.
5. Drag the dockPanel to the form and set the Dock attribute. I set Fill.Note that the menu toolbar is added first and thenDockpanelOtherwise, the layout interface is not displayed completely.
The specific design interface is as follows:
Add a form on the left and design it as the outlookbar style. It is actually in a docked form, inherited from WeifenLuo. WinFormsUI. Dockin
common one is to drag a Button in Windows to generate a XAML code similar to this:How is the position of the control during rendering determined by using the Margin attribute? We can say that the control is determined by ourselves, or that it is determined by WPF ".
Besides, WPF also provides another layout method, that is, layout objects. The biggest feature of this layout method is that,The parent control centrally manages the layout of child objects.. Such controls include Border, StackPanel
simple to implement these tasks. The demo below demonstrates how to simply not manually write a line of background Logic Code To solve the problem above, you can paste the following code to xamlpad: Window Xmlns = "Http://schemas.microsoft.com/winfx/2006/xaml/presentation" Xmlns: x = "Http://schemas.microsoft.com/winfx/2006/xaml" X: Name = "Window" Title = "Window1" Width = "640" Height = "480" > Dockpanel Lastchildfill = "True"
In a desktop application, if the size of the form changes, and the size of the content in the form remains the same, the blank background color is different from the desktop background, which will become very ugly and the user experience is poor, one solution to this problem is adaptive screen resolution. The following describes how to adapt to the screen resolution. First, let's take a look at the effect,
Figure 1-initial screen size
Figure 2-Full Screen
The container control uses
example is applied to the basic graph, the generated graph is as follows. This is a OneWay binding, because the Background attribute supports OneWay binding by default.
You may wonder why, even if the ColorName attribute is a type string and the Background attribute is of the Brush type. This is because of the default type conversion. This type conversion is discussed in the data conversion section.
Bind SourceNote that in the previous example, the binding source is specified by setting the da
of simple components, as long as we reasonably break it down;Complex design does not mean complex implementation. Similarly, simple design does not mean simple implementation;However, there is no simple design to meet complex challenges, but it is usually the beginning of a nightmare.
F5Run and check the result!
02. Create a component
I often call user control a component and custom control a control.
In short, user control is usually generated by combining multiple controls, while c
the tile policy is generally fixed or adaptive, and the cell size is calculated according to all the elements of the visible view, and all cells remain the same size. containers Container Generic Container list Box (Hbox, VBox) linear layout, horizontal, vertical dockpanel docking layout, up and down the SplitContainer split containers cardbox card box layout, one-page display accordion accordion layout, single expansion grid table layout Too Lbox, T
.
Then bind in the DockPanel, refer directly to the XX resource, the object that you just defined and assigned the value:
In this way, the corresponding background constructor changes to:
public Window1() { InitializeComponent(); this.addButton.Click += addButton_Click; // get names collection from resources this.names = (Nicknames)this.FindResource("XX"); // no need to make data available for binding here //dockPanel.DataCont
validate method. Let the Code explain everything:
In actual projects, you may not like the error prompt dialog box very much. The best way is to use the tooltip for Windows form verification, however, it is worth noting that validaterule does not have a tooltip similar to the validatesucess event, which makes the display of the entire tooltip very strange. 2.9 binding path syntax
The descriptions on msdn are listed below:
You can use the path attribute to specify the source value to
Reference method:1. Create a WinForm project, and a WinForm form is generated by default.2. Refer to add Reference, browse->weifenluo.winformsui.docking.dll.3. Form Properties Ismdicontainer:true.4. Browse->weifenluo.winformsui.docking.dll-> in the Toolbox with the option->.net component, right-click, Toolbox, DockPanel.5. Drag the DockPanel onto the form, set the Dock property, I set the: Fill.Docked form:
Original: WPF notes (1.9 styles and control templates)--hello,wpf!Another use of resources is style settings:Window>window.resources>Style x:key="MyStyle"TargetType="{x:type TextBlock}">Setter Property="VerticalAlignment"Value="Center"/>Setter Property="FontWeight"Value="Bold"/>Setter Property="FontStyle"Value="Italic"/>Style>window.resources>DockPanel>StackPanel>TextBlock Style="{StaticResource MyStyle}">Name:TextBlock>TextBox Text="{Binding Path=nam
11:21:59 basic usage
When I saw my colleagues using this component, it worked very well. I also wanted to learn and apply it to other projects in the future.
Reference Method:
1. Create a winform project. A winform form is generated by default.
2. Reference-> Add reference-> browse-> weifenluo. winformsui. Docking. dll.
3. Form attribute ismdicontainer: True.
4. Right-click the Toolkit and choose items>. NET components> browse> weifenluo. winformsui. Docking. dll>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.