我想使用generic.xaml创建自定义控件数据网格。我已经使用Silverlight 5中的用户控件模板创建了自定义控件。我没有使用WPF。如何使用generic.xaml创建?
您描述的内容Templated Control
在Silverlight中称为“ a” 。
您必须提供三件事:
Style
的ControlTemplate
generic.xaml
包含默认值的条目Style
示例:MyFeeblefezer.cs
public class MyFeeblefezer : Control
{
public MyFeeblefezer() { DefaultStyleKey = typeof(MyFeeblefezer); }
}
和MyFeeblefezer.xaml
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="MyFeeblefezer">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="MyFeeblefezer">
<Grid>
<!-- here goes your visible control UI parts -->
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
和主题/generic.xaml
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/MyFeebleProject;Component/MyFeeblefezer.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句