开发者

User Control problem

I want to create my own DataGrid control. Add my project User Control and derive it from 开发者_如何学GoDataGrid but it gives and error in buid.

DataGridControl.xaml.cs : public partial class DataGridControl : DataGrid { ...some codes }

Error : Partial declarations of 'DataGridControl' must not specify different base classes .. DataGridControl.g.i.cs

I change this row public partial class DataGridControl : System.Windows.Controls.UserControl to public partial class DataGridControl : System.Windows.Controls.DataGrid in DataGridControl.g.i.cs file but it back againg automatically.

How can I solve this problem please help


If you check the DataGrid reference, you can see that it's inheriting from Control and not UserControl, that's why you can't make it the way you wanted.

What you can do however, is to create a Custom Control, which is just a C# class extending DataGrid. You can then add that to your layout using a XAML namespace include, template using the default DataGrid template as a starting point and implement all the custom functionality you want in your custom class.

For more info see this tutorial: http://www.silverlightshow.net/items/Creating-a-Silverlight-Custom-Control-The-Basics.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜