Partial declarations must not specify different base classes

前端 未结 8 1425
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-05 22:14

Guys I am new to WPF .

I have a wpf page named StandardsDefault. In the code behind, StandardsDefault is inheriting Page, l

相关标签:
8条回答
  • 2020-12-05 23:14

    In your CountryStandards.xaml you should write

    <StandardsDefault x:Class="namespace.CountryStandards"...
    
    0 讨论(0)
  • 2020-12-05 23:16

    I did a complete cheat and used dynamic, probably breaks every rule in the book lol

            Assembly a = Assembly.GetExecutingAssembly(); //get this app
    
            List<dynamic> l = new List<dynamic>(); //create a list
    
            // this list is our objects as string names
            // this if the full namespace and class, not just the class name 
            // I've actually stored these in my database so that I can control
            // ordering and show/hide from the database
            foreach(var app in listApplications) 
            {
                l.Add(a.CreateInstance(app)); //add them to my list
            }
    
            //as all my objects are the same this still works, you just don't get 
            //Intellisync which I don't care about because I know what I'm sending
            //all my objects are autonomous and self-contained and know nothing of any other objects
            //i have a main window/code that marshals the controls and data and manages view navigation
            l[0].DoThatFunction({ status ="new", message ="start", value = 0});
    

    And then on the class

        public void DoThatFunction(dynamic data)
        {
            MessageBox.Show(data.message);//place-holder code but i'm sure you get the idea
        }
    

    I like this because is oh so loosely coupled. As I'm porting an old app from Winforms to WPF this suits me as I can literally just copy and paste any code that's compatible. It might be the wrong thing to do but it works and will save me a ton of rework.

    Also makes testing easy as I can 100% focus on each control in turn

    0 讨论(0)
提交回复
热议问题