In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about the two special properties of the Button control in Silverlight. The article is rich in content and analyzes and describes it from a professional point of view. I hope you can get something after reading this article.
Before you begin to introduce the Content attribute, please remember the following inheritance tree:
Control (abstract) ContentControl Frame PhoneApplicationFrame UserControl Page PhoneApplicationPage
Notice that the Content property in ContentControl is an object object!
In Silverlight, Button is derived from ContentControl and indirectly from Control. Because the Button control has the Content property of the ContentControl control, where the Content property is the object object, we can define the content of the Button control with the following code:
Click this Button!
On the face of it, the above code is correct, but this is not allowed in silverlight. In addition, the Content attribute element tag of any control derived from the ContentControl control can be ignored, so the changed code is as follows:
Xmlns:system= "clr-namespace;assembly=mscorlib" Click this Button
If you don't like the Button control to display only general text content, you can also set its Content property content to another element, but the element must be a FrameworkElement derived object. For example, set the Content property of the Button control to a picture:
Because the Button control is a ContentControl derived element, the syntax form of the Button.Content attribute element can be omitted.
You can also set a special format for the text within the Buton control, for example, the following code sets the text content in italics:
Click Me!
If you want to set the Content property content of the Button control to an ellipse with a gradient brush, we need to use the ContentTemplate property; because as shown above, if you want to set the Content property content of the Button control to non-text content, you have to set its Content property content to the FrameworkElement class derived element, and here it is the ellipse containing a gradient brush, and the gradient brush is not an FrameworkElement derived element, so you have to control the ContentTemplate content template of the Button control.
The relevant XAML codes are:
The display results are as follows:
In the above XAML code, there is a special Binding syntax tag, which sets neither Source nor ElementName or Path properties, but only "{Binding}", which indicates that the binding content is the above gradient brush; the above code actually changes part of the visual tree of the Button control, and the visual tree of its standard Button control is in the form of:
After setting up the ContentTemplate here, the visual tree of the control has been changed into the following form:
The value of the ContentTemplate property of the Button control is of type DataTemplate. Setting DataTemplate can change part of the visual tree of the control!
These are the two special properties of the Button control in Silverlight shared by Xiaobian. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.