BenHayat1p said 5 years, 6 months ago:
I think one way to learn SL, is looking at these demos and figure out what the [experts] at C1 have done.
Looking at Control Explorer demo, I see two classes as part of the project: ControlNode and DemoTemplate.
Were these classes made particularly for these demos or are classes something we need to add to our apps?
Second question, is about "generic.xaml". Again is this used as part of using your Treeview component or is this for the demo only?
C1_MaxM7p said 5 years, 6 months ago:
ControlNode and DemoTemplate were made particularly for the explorer app, but that doesn't mean you can't learn from them. ControlNode is an example of a specialized control. It shows how you can change the behavior and look of a silverlight control. ControlNode inherits from C1TreeViewItem, that allows it to attach some data to the tree, and also specialize the behavior in a small way: it expand and collapses by clicking on the tree header.
The style of ControlNode is defined in generic.xaml. If you look into generic.xaml you will see a Style with ControlNode as its TargetType, but without a key. This style is applied to all ControlNodes by the Silverlight runtime. So generic.xaml is the place wherer you put default styles for your controls. In the current silverlight release it's not possible to set default styles for controls from other assemblies. Therefore, if you want to style our controls or Microsoft's, you must inherit from them or set the Style property manually.
There is a generic.xaml stored as a resource in the C1 Silverlight assembly, which contains the default styles for all of our controls. We will probably release this in the future. It's much easier to style a control starting from a complete template.
C1_BernardoC17p said 5 years, 6 months ago:
The ControlNode and DemoTemplate classes were created specifically for this demo.
ControlNode is a class that derives from TreeViewItem and adds properties and methods that identify the specific control that this node represents. This is a convenient way to use the TreeView control. The alternative would be to use the Tag property to attach custom information to plain TreeViewItem objects.
DemoTemplate is a a generic control holder class. It uses reflection to instantiate controls and to expose some of its properties for demo purposes. This class makes it easy for us to add controls to the demo or to change the way they are demonstrated. If you inspect the demo project, you will notice an XML file that contains the list of controls that should be demonstrated and how they should be demonstrated.
The 'generic.xaml' file contains Styles that are applied to controls. In this sample, it defines the Style for the custom TreeViewItem class. The nodes in the sample show plus/minus images instead of the default collapse/expand icons. This is just one way to customize the look of your applications.
You must be logged in to reply to this topic.