none
Legacy in WPF RRS feed

  • Question

  • Hi everyone,

    I want to know PLZ how to do legacy with WPF: a "Chlid User Control" that inherits xaml controls and c# events  from a "Mother User Control"

    Thanks
    Wednesday, March 3, 2010 9:51 AM

Answers

  • Hi,

    If you want to inherit child window from the WPF window,
    To do this. see code below.. Hope this helps.

     

    public class CoreWin : Window

    {

    }

     

    public class ChilWindow : CoreWin

    {

     

    public ChilWindow()

    {

    }

    }

    Regards,

    giovhan


    vb.net GUI
    Thursday, March 4, 2010 8:37 AM

All replies

  • Hi,

    Can you elaborate your question? I'm afraid I don't quite understand what exactly you want to do.

    Thanks,
    Jie
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    If you have any feedback, please tell us.

    The All-In-One Code Framework Project
    My Blog (in Simplified Chinese)
    Thursday, March 4, 2010 2:37 AM
    Moderator
  • hi,
    okay.

    I want to create 2 windows with WPF: "baseWindows" and "ChildWindow".
    I want that the "ChildWindow" inherits from "baseWindow".

    I tried this in C#:

     public partial class ChildWindow : baseWindow
        {
            public UserControl2()
            {
                
            }
    }


    But this code doesn't work and i don't know what should i add in xaml code.

    Plz help.
    Thanks
    Thursday, March 4, 2010 8:22 AM
  • Hi,

    If you want to inherit child window from the WPF window,
    To do this. see code below.. Hope this helps.

     

    public class CoreWin : Window

    {

    }

     

    public class ChilWindow : CoreWin

    {

     

    public ChilWindow()

    {

    }

    }

    Regards,

    giovhan


    vb.net GUI
    Thursday, March 4, 2010 8:37 AM
  • Hi,

    Let me clarify the things.

    First you need to create an abstract class that inherits the from WindowBase.  This class should
    be your WindowCore.  After that you can inherit this class to your child window. 
    Dont forget to add-reference the windowBase.dll.

    then your XAML should look like this.  Take note of the scr:

    <

     

    scr:WindowCore x:Class="WpfApplication4C.Window2"

     

     

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

     

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

     

    xmlns:scr="clr-namespace:WpfApplication4C"

     

    Title="Window2" Height="300" Width="300">

     

     

    <Grid>

     

     

     

    </Grid>

    </

     

    scr:WindowCore>


    then code behind should inherit the WindowCore.

    Hope that helps.

    gioVhan


    vb.net GUI
    Thursday, March 4, 2010 8:54 AM