当前位置:网站首页>Blend for visual studio overview

Blend for visual studio overview

2022-06-11 00:58:00 Nidhogg_ com

Blend for Visual Studio Can be used to design based on XAML Of Windows and Web Applications . It provides And Visual studio Same basic XAML Design experience , And added a visual designer , For advanced tasks , Such as animation and behavior . of Blend and Visual Studio Comparison between , Please refer to at Visual Studio and Blend for Visual Studio Middle design XAML. Blend for Visual Studio yes Visual Studio A component of . If you want to install Blend, Please be there. Visual Studio In setup , choice “ Universal Windows Platform development ” or “.NET Desktop development ” The workload . Both workloads include Blend for Visual Studio Components .

WPF Control's default style
( One ) Check the style
WPF Common controls in have a default custom style , stay Visual Studio Cannot be viewed directly in , But in
Blend for Visual Studio Can be viewed through templates .
As shown below :
(1) In the lower left corner “ Objects and timelines ” The palette , Find the corresponding control , Right click to open the context menu , Click on Edit templates -> Edit copy
(2) Select the name of the style ( keyword ) And define the location .
stay “ name ( keyword )” in , If you choose the first line , Then the style contains custom x:Key attribute ; If second is selected That's ok , There is no key, Will be automatically assigned to Type Application style .
stay “ Define the location ” in , first line “ Applications ” The presentation style will be placed in app.xaml in , The second line goes to the current xaml In the document ; The third line represents the custom resource dictionary .
(3) Click OK to generate the corresponding style , The style also contains ControlTemplate. You can change it yourself .

WPF Medium ControlTemplate
WPF Contains data templates and control templates , The control template also includes ControlTemplate and ItemsPanelTemplate, Let's talk about ControlTemplate.
Actually WPF Each control of the has a default template , This template describes the appearance of the control ( Visual tree ) as well as The response of appearance to external stimuli ( trigger ). We can customize a template to replace the control Default templates to create personalized controls .
And Style Different ,Style Only the existing property values of the control can be changed ( Such as color font ) To customize the controls , But the control template can change the internal structure of the control (VisualTree, Visual tree ) To complete more complex customization , For example, we can To customize such buttons : It displays a small icon in the left part and text in the right part . want Replace the template of the control , We just need to declare one ControlTemplate object , And ControlTemplate Yes Like making corresponding configuration , Then the ControlTemplate Object assigned to the control Template Properties will do .
ControlTemplate Contains two important properties :
1.VisualTree, The visual tree of the template , In fact, we use this property to describe the appearance of the control
2.Triggers, Trigger list , It contains some triggers Trigger, We can customize this trigger column Table to make the control respond to external stimuli , For example, the text becomes bold when the mouse passes .

原网站

版权声明
本文为[Nidhogg_ com]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020626176318.html