locked
Customised ListView control as user control RRS feed

  • Question

  • Hello,

    I am creating a customised ListView control. I have my control class derived from the ListView control. I am planning to deploy it as a user control. However, I see that the usercontrols are derived from something called UserControl. How to have a customised ListView control deployed as a user control?

    Thanks in advance.
    Friday, March 12, 2010 9:18 AM

Answers

  • Hi xl3k,

    I guess it would make sense to first clarify as to whether you really need a custom control (i.e. one that extends the functionality of the regular ListView control itself) or whether you just want to change its appearance, in which case you would create a style. Also, you need to distinguish between a custom control (i.e. you inherit from ListView) and a UserControl, the latter offering to i.e. provide a group of controls that can be re-used.
    Cheers,
    Olaf
    http://blogs.intuidev.com
    Friday, March 12, 2010 10:12 AM
  • Hi,

    Based on your demonstration, I think you are looking for a custom control, so you can reuse it throughout your applicaton, please refer to this code project sample on how to create a custom control:
    http://www.codeproject.com/KB/WPF/WPFCustomControl.aspx

    Thanks.
    Sincerely.
    Jim Zhou -MSFT
    Monday, March 15, 2010 1:16 PM

All replies

  • Maybe you don't really mean a usercontrol.

    Say you write a class that inherits from ListView or GridView or whatever.
    That's a class in your assembly once compiled.
    To use that in a window you add an <xmls:   reference in the top of your window with the other ones, except that aliases your clr assembly.
    Say you pick <xmlns:local

    You would then use your listview:

    <local:MyListView> blaa </local:MyLIstView>

    Is that what you want to do?
    Friday, March 12, 2010 9:26 AM
  • Hi xl3k,

    I guess it would make sense to first clarify as to whether you really need a custom control (i.e. one that extends the functionality of the regular ListView control itself) or whether you just want to change its appearance, in which case you would create a style. Also, you need to distinguish between a custom control (i.e. you inherit from ListView) and a UserControl, the latter offering to i.e. provide a group of controls that can be re-used.
    Cheers,
    Olaf
    http://blogs.intuidev.com
    Friday, March 12, 2010 10:12 AM
  • I need to extend the functionality of the ListView control and I need to reuse this control at different places, something like the way I can reuse an activex control.
    Friday, March 12, 2010 10:35 AM
  • Hi xl3k,

    take a look at this CodeProject article that provides a starter on how to create custom controls.
    Cheers,
    Olaf
    http://blogs.intuidev.com
    Friday, March 12, 2010 11:23 AM
  • Hi,

    Based on your demonstration, I think you are looking for a custom control, so you can reuse it throughout your applicaton, please refer to this code project sample on how to create a custom control:
    http://www.codeproject.com/KB/WPF/WPFCustomControl.aspx

    Thanks.
    Sincerely.
    Jim Zhou -MSFT
    Monday, March 15, 2010 1:16 PM