Why I can't update the UI when binding a class inherits the interface?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I am trying to write a demo of binding a class inherits the interface.


Here is the code of interface:



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace App1
{
public interface BaseClass
{
string AAA { get; set; }
}
}


Here is code-behind of the Page:



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

namespace App1
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page, INotifyPropertyChanged
{
public BaseClass BC;
public static MainPage MP;
public MainPage()
{
this.InitializeComponent();
MP = this;
BC = new ChildClass();
}

public event PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(string name)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
public class ChildClass : BaseClass
{
string _AAA = "123";
public string AAA
{
get { return _AAA; }
set { _AAA = value; MP.RaisePropertyChanged("AAA"); }
}

}

private void Button_Click(object sender, RoutedEventArgs e)
{
BC.AAA = "456";
}
}
}


And finally here is the XAML:



<Page
x:Class="App1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Text="{x:Bind BC.AAA,Mode=OneWay}"></TextBlock>
<Button Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="Button_Click">123</Button>
</Grid>
</Page>


After I ran the program, it will display the default string of AAA successfully. However, when I clicked the button, it can't change the text to "456".


I wonder if there is the INotifyPropertyChanged problem. But I don't know what's wrong with it.


Would you please tell me what's wrong with this? Thank you.










share|improve this question





























    0















    I am trying to write a demo of binding a class inherits the interface.


    Here is the code of interface:



    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    namespace App1
    {
    public interface BaseClass
    {
    string AAA { get; set; }
    }
    }


    Here is code-behind of the Page:



    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.IO;
    using System.Linq;
    using System.Runtime.InteropServices.WindowsRuntime;
    using Windows.Foundation;
    using Windows.Foundation.Collections;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    using Windows.UI.Xaml.Controls.Primitives;
    using Windows.UI.Xaml.Data;
    using Windows.UI.Xaml.Input;
    using Windows.UI.Xaml.Media;
    using Windows.UI.Xaml.Navigation;

    // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

    namespace App1
    {
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page, INotifyPropertyChanged
    {
    public BaseClass BC;
    public static MainPage MP;
    public MainPage()
    {
    this.InitializeComponent();
    MP = this;
    BC = new ChildClass();
    }

    public event PropertyChangedEventHandler PropertyChanged;
    protected void RaisePropertyChanged(string name)
    {
    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
    }
    public class ChildClass : BaseClass
    {
    string _AAA = "123";
    public string AAA
    {
    get { return _AAA; }
    set { _AAA = value; MP.RaisePropertyChanged("AAA"); }
    }

    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {
    BC.AAA = "456";
    }
    }
    }


    And finally here is the XAML:



    <Page
    x:Class="App1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid>
    <Grid.RowDefinitions>
    <RowDefinition></RowDefinition>
    <RowDefinition></RowDefinition>
    </Grid.RowDefinitions>
    <TextBlock Text="{x:Bind BC.AAA,Mode=OneWay}"></TextBlock>
    <Button Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="Button_Click">123</Button>
    </Grid>
    </Page>


    After I ran the program, it will display the default string of AAA successfully. However, when I clicked the button, it can't change the text to "456".


    I wonder if there is the INotifyPropertyChanged problem. But I don't know what's wrong with it.


    Would you please tell me what's wrong with this? Thank you.










    share|improve this question

























      0












      0








      0








      I am trying to write a demo of binding a class inherits the interface.


      Here is the code of interface:



      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;

      namespace App1
      {
      public interface BaseClass
      {
      string AAA { get; set; }
      }
      }


      Here is code-behind of the Page:



      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.IO;
      using System.Linq;
      using System.Runtime.InteropServices.WindowsRuntime;
      using Windows.Foundation;
      using Windows.Foundation.Collections;
      using Windows.UI.Xaml;
      using Windows.UI.Xaml.Controls;
      using Windows.UI.Xaml.Controls.Primitives;
      using Windows.UI.Xaml.Data;
      using Windows.UI.Xaml.Input;
      using Windows.UI.Xaml.Media;
      using Windows.UI.Xaml.Navigation;

      // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

      namespace App1
      {
      /// <summary>
      /// An empty page that can be used on its own or navigated to within a Frame.
      /// </summary>
      public sealed partial class MainPage : Page, INotifyPropertyChanged
      {
      public BaseClass BC;
      public static MainPage MP;
      public MainPage()
      {
      this.InitializeComponent();
      MP = this;
      BC = new ChildClass();
      }

      public event PropertyChangedEventHandler PropertyChanged;
      protected void RaisePropertyChanged(string name)
      {
      PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
      }
      public class ChildClass : BaseClass
      {
      string _AAA = "123";
      public string AAA
      {
      get { return _AAA; }
      set { _AAA = value; MP.RaisePropertyChanged("AAA"); }
      }

      }

      private void Button_Click(object sender, RoutedEventArgs e)
      {
      BC.AAA = "456";
      }
      }
      }


      And finally here is the XAML:



      <Page
      x:Class="App1.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="using:App1"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      mc:Ignorable="d"
      Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

      <Grid>
      <Grid.RowDefinitions>
      <RowDefinition></RowDefinition>
      <RowDefinition></RowDefinition>
      </Grid.RowDefinitions>
      <TextBlock Text="{x:Bind BC.AAA,Mode=OneWay}"></TextBlock>
      <Button Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="Button_Click">123</Button>
      </Grid>
      </Page>


      After I ran the program, it will display the default string of AAA successfully. However, when I clicked the button, it can't change the text to "456".


      I wonder if there is the INotifyPropertyChanged problem. But I don't know what's wrong with it.


      Would you please tell me what's wrong with this? Thank you.










      share|improve this question














      I am trying to write a demo of binding a class inherits the interface.


      Here is the code of interface:



      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;

      namespace App1
      {
      public interface BaseClass
      {
      string AAA { get; set; }
      }
      }


      Here is code-behind of the Page:



      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.IO;
      using System.Linq;
      using System.Runtime.InteropServices.WindowsRuntime;
      using Windows.Foundation;
      using Windows.Foundation.Collections;
      using Windows.UI.Xaml;
      using Windows.UI.Xaml.Controls;
      using Windows.UI.Xaml.Controls.Primitives;
      using Windows.UI.Xaml.Data;
      using Windows.UI.Xaml.Input;
      using Windows.UI.Xaml.Media;
      using Windows.UI.Xaml.Navigation;

      // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

      namespace App1
      {
      /// <summary>
      /// An empty page that can be used on its own or navigated to within a Frame.
      /// </summary>
      public sealed partial class MainPage : Page, INotifyPropertyChanged
      {
      public BaseClass BC;
      public static MainPage MP;
      public MainPage()
      {
      this.InitializeComponent();
      MP = this;
      BC = new ChildClass();
      }

      public event PropertyChangedEventHandler PropertyChanged;
      protected void RaisePropertyChanged(string name)
      {
      PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
      }
      public class ChildClass : BaseClass
      {
      string _AAA = "123";
      public string AAA
      {
      get { return _AAA; }
      set { _AAA = value; MP.RaisePropertyChanged("AAA"); }
      }

      }

      private void Button_Click(object sender, RoutedEventArgs e)
      {
      BC.AAA = "456";
      }
      }
      }


      And finally here is the XAML:



      <Page
      x:Class="App1.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="using:App1"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      mc:Ignorable="d"
      Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

      <Grid>
      <Grid.RowDefinitions>
      <RowDefinition></RowDefinition>
      <RowDefinition></RowDefinition>
      </Grid.RowDefinitions>
      <TextBlock Text="{x:Bind BC.AAA,Mode=OneWay}"></TextBlock>
      <Button Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="Button_Click">123</Button>
      </Grid>
      </Page>


      After I ran the program, it will display the default string of AAA successfully. However, when I clicked the button, it can't change the text to "456".


      I wonder if there is the INotifyPropertyChanged problem. But I don't know what's wrong with it.


      Would you please tell me what's wrong with this? Thank you.







      uwp uwp-xaml






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 16 '18 at 14:37









      102425074102425074

      236110




      236110
























          1 Answer
          1






          active

          oldest

          votes


















          1














          2 mistakes:



          First:



          Notice that the ChidClass calls to MP.RaisePropertyChanged("AAA"), not the BaseClass. So, instead of declaring BC like



          public BaseClass BC;



          do



          public ChildClass BC; instead.



          Second:
          the property AAA doesn't belong to MainPage class, it belongs to ChildClass, so instead of implementing INotifyPropertyChanged in the MainPage, implement it in the ChildClass:



          public class ChildClass : BaseClass, INotifyPropertyChanged
          {
          string _AAA = "123";
          public string AAA
          {
          get { return _AAA; }
          set { _AAA = value; RaisePropertyChanged("AAA"); }
          }
          public event PropertyChangedEventHandler PropertyChanged;
          protected void RaisePropertyChanged(string name)
          {
          PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
          }
          }


          This should work.



          Edit:
          The first mistake you made, if it was on intention, because you want to bind the UIs to this interface, then Sorry, you can't do that.



          Why? because, to achieve that, you need to raise INotifyPropertyChanged event in that interface, but interfaces in c# (currently c# 7.3) doesn't let you do any default implementation, which means you can't write any code to raise that event. Having said that, C# 8.0, which is coming in near future, will have this capability. Can you wait till then?






          share|improve this answer


























          • I modified it as you said and it worked. But the most important question is the first mistake you said, that's what I do it intentionally. I wanna binding an interface to the UI, whenever someone inherits the interface and set it to the public BaseClass BC, the UI will automatically update with the new class.

            – 102425074
            Nov 17 '18 at 1:24











          • Anyhow, the UI and interface are in a dll which to reference by other program, so that I have to binding the interface to UI and let others to update the UI by creating a new class which inherit the interface. Would you please tell me how I can do this, thank you.

            – 102425074
            Nov 17 '18 at 1:26











          • see my edited answer

            – Muzib
            Nov 17 '18 at 7:01











          • Someone told me that I can use an abstract class to do it, I tried but failed. Now I think I can only set a property to the binding and change the property via the class. Thank you.

            – 102425074
            Nov 17 '18 at 13:27











          • Yes , he/she is right. An abstract class can do that. If you have no problem with abstract classes, then go on.

            – Muzib
            Nov 17 '18 at 14:17












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53339929%2fwhy-i-cant-update-the-ui-when-binding-a-class-inherits-the-interface%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          2 mistakes:



          First:



          Notice that the ChidClass calls to MP.RaisePropertyChanged("AAA"), not the BaseClass. So, instead of declaring BC like



          public BaseClass BC;



          do



          public ChildClass BC; instead.



          Second:
          the property AAA doesn't belong to MainPage class, it belongs to ChildClass, so instead of implementing INotifyPropertyChanged in the MainPage, implement it in the ChildClass:



          public class ChildClass : BaseClass, INotifyPropertyChanged
          {
          string _AAA = "123";
          public string AAA
          {
          get { return _AAA; }
          set { _AAA = value; RaisePropertyChanged("AAA"); }
          }
          public event PropertyChangedEventHandler PropertyChanged;
          protected void RaisePropertyChanged(string name)
          {
          PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
          }
          }


          This should work.



          Edit:
          The first mistake you made, if it was on intention, because you want to bind the UIs to this interface, then Sorry, you can't do that.



          Why? because, to achieve that, you need to raise INotifyPropertyChanged event in that interface, but interfaces in c# (currently c# 7.3) doesn't let you do any default implementation, which means you can't write any code to raise that event. Having said that, C# 8.0, which is coming in near future, will have this capability. Can you wait till then?






          share|improve this answer


























          • I modified it as you said and it worked. But the most important question is the first mistake you said, that's what I do it intentionally. I wanna binding an interface to the UI, whenever someone inherits the interface and set it to the public BaseClass BC, the UI will automatically update with the new class.

            – 102425074
            Nov 17 '18 at 1:24











          • Anyhow, the UI and interface are in a dll which to reference by other program, so that I have to binding the interface to UI and let others to update the UI by creating a new class which inherit the interface. Would you please tell me how I can do this, thank you.

            – 102425074
            Nov 17 '18 at 1:26











          • see my edited answer

            – Muzib
            Nov 17 '18 at 7:01











          • Someone told me that I can use an abstract class to do it, I tried but failed. Now I think I can only set a property to the binding and change the property via the class. Thank you.

            – 102425074
            Nov 17 '18 at 13:27











          • Yes , he/she is right. An abstract class can do that. If you have no problem with abstract classes, then go on.

            – Muzib
            Nov 17 '18 at 14:17
















          1














          2 mistakes:



          First:



          Notice that the ChidClass calls to MP.RaisePropertyChanged("AAA"), not the BaseClass. So, instead of declaring BC like



          public BaseClass BC;



          do



          public ChildClass BC; instead.



          Second:
          the property AAA doesn't belong to MainPage class, it belongs to ChildClass, so instead of implementing INotifyPropertyChanged in the MainPage, implement it in the ChildClass:



          public class ChildClass : BaseClass, INotifyPropertyChanged
          {
          string _AAA = "123";
          public string AAA
          {
          get { return _AAA; }
          set { _AAA = value; RaisePropertyChanged("AAA"); }
          }
          public event PropertyChangedEventHandler PropertyChanged;
          protected void RaisePropertyChanged(string name)
          {
          PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
          }
          }


          This should work.



          Edit:
          The first mistake you made, if it was on intention, because you want to bind the UIs to this interface, then Sorry, you can't do that.



          Why? because, to achieve that, you need to raise INotifyPropertyChanged event in that interface, but interfaces in c# (currently c# 7.3) doesn't let you do any default implementation, which means you can't write any code to raise that event. Having said that, C# 8.0, which is coming in near future, will have this capability. Can you wait till then?






          share|improve this answer


























          • I modified it as you said and it worked. But the most important question is the first mistake you said, that's what I do it intentionally. I wanna binding an interface to the UI, whenever someone inherits the interface and set it to the public BaseClass BC, the UI will automatically update with the new class.

            – 102425074
            Nov 17 '18 at 1:24











          • Anyhow, the UI and interface are in a dll which to reference by other program, so that I have to binding the interface to UI and let others to update the UI by creating a new class which inherit the interface. Would you please tell me how I can do this, thank you.

            – 102425074
            Nov 17 '18 at 1:26











          • see my edited answer

            – Muzib
            Nov 17 '18 at 7:01











          • Someone told me that I can use an abstract class to do it, I tried but failed. Now I think I can only set a property to the binding and change the property via the class. Thank you.

            – 102425074
            Nov 17 '18 at 13:27











          • Yes , he/she is right. An abstract class can do that. If you have no problem with abstract classes, then go on.

            – Muzib
            Nov 17 '18 at 14:17














          1












          1








          1







          2 mistakes:



          First:



          Notice that the ChidClass calls to MP.RaisePropertyChanged("AAA"), not the BaseClass. So, instead of declaring BC like



          public BaseClass BC;



          do



          public ChildClass BC; instead.



          Second:
          the property AAA doesn't belong to MainPage class, it belongs to ChildClass, so instead of implementing INotifyPropertyChanged in the MainPage, implement it in the ChildClass:



          public class ChildClass : BaseClass, INotifyPropertyChanged
          {
          string _AAA = "123";
          public string AAA
          {
          get { return _AAA; }
          set { _AAA = value; RaisePropertyChanged("AAA"); }
          }
          public event PropertyChangedEventHandler PropertyChanged;
          protected void RaisePropertyChanged(string name)
          {
          PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
          }
          }


          This should work.



          Edit:
          The first mistake you made, if it was on intention, because you want to bind the UIs to this interface, then Sorry, you can't do that.



          Why? because, to achieve that, you need to raise INotifyPropertyChanged event in that interface, but interfaces in c# (currently c# 7.3) doesn't let you do any default implementation, which means you can't write any code to raise that event. Having said that, C# 8.0, which is coming in near future, will have this capability. Can you wait till then?






          share|improve this answer















          2 mistakes:



          First:



          Notice that the ChidClass calls to MP.RaisePropertyChanged("AAA"), not the BaseClass. So, instead of declaring BC like



          public BaseClass BC;



          do



          public ChildClass BC; instead.



          Second:
          the property AAA doesn't belong to MainPage class, it belongs to ChildClass, so instead of implementing INotifyPropertyChanged in the MainPage, implement it in the ChildClass:



          public class ChildClass : BaseClass, INotifyPropertyChanged
          {
          string _AAA = "123";
          public string AAA
          {
          get { return _AAA; }
          set { _AAA = value; RaisePropertyChanged("AAA"); }
          }
          public event PropertyChangedEventHandler PropertyChanged;
          protected void RaisePropertyChanged(string name)
          {
          PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
          }
          }


          This should work.



          Edit:
          The first mistake you made, if it was on intention, because you want to bind the UIs to this interface, then Sorry, you can't do that.



          Why? because, to achieve that, you need to raise INotifyPropertyChanged event in that interface, but interfaces in c# (currently c# 7.3) doesn't let you do any default implementation, which means you can't write any code to raise that event. Having said that, C# 8.0, which is coming in near future, will have this capability. Can you wait till then?







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 17 '18 at 7:01

























          answered Nov 16 '18 at 18:32









          MuzibMuzib

          1,1591820




          1,1591820













          • I modified it as you said and it worked. But the most important question is the first mistake you said, that's what I do it intentionally. I wanna binding an interface to the UI, whenever someone inherits the interface and set it to the public BaseClass BC, the UI will automatically update with the new class.

            – 102425074
            Nov 17 '18 at 1:24











          • Anyhow, the UI and interface are in a dll which to reference by other program, so that I have to binding the interface to UI and let others to update the UI by creating a new class which inherit the interface. Would you please tell me how I can do this, thank you.

            – 102425074
            Nov 17 '18 at 1:26











          • see my edited answer

            – Muzib
            Nov 17 '18 at 7:01











          • Someone told me that I can use an abstract class to do it, I tried but failed. Now I think I can only set a property to the binding and change the property via the class. Thank you.

            – 102425074
            Nov 17 '18 at 13:27











          • Yes , he/she is right. An abstract class can do that. If you have no problem with abstract classes, then go on.

            – Muzib
            Nov 17 '18 at 14:17



















          • I modified it as you said and it worked. But the most important question is the first mistake you said, that's what I do it intentionally. I wanna binding an interface to the UI, whenever someone inherits the interface and set it to the public BaseClass BC, the UI will automatically update with the new class.

            – 102425074
            Nov 17 '18 at 1:24











          • Anyhow, the UI and interface are in a dll which to reference by other program, so that I have to binding the interface to UI and let others to update the UI by creating a new class which inherit the interface. Would you please tell me how I can do this, thank you.

            – 102425074
            Nov 17 '18 at 1:26











          • see my edited answer

            – Muzib
            Nov 17 '18 at 7:01











          • Someone told me that I can use an abstract class to do it, I tried but failed. Now I think I can only set a property to the binding and change the property via the class. Thank you.

            – 102425074
            Nov 17 '18 at 13:27











          • Yes , he/she is right. An abstract class can do that. If you have no problem with abstract classes, then go on.

            – Muzib
            Nov 17 '18 at 14:17

















          I modified it as you said and it worked. But the most important question is the first mistake you said, that's what I do it intentionally. I wanna binding an interface to the UI, whenever someone inherits the interface and set it to the public BaseClass BC, the UI will automatically update with the new class.

          – 102425074
          Nov 17 '18 at 1:24





          I modified it as you said and it worked. But the most important question is the first mistake you said, that's what I do it intentionally. I wanna binding an interface to the UI, whenever someone inherits the interface and set it to the public BaseClass BC, the UI will automatically update with the new class.

          – 102425074
          Nov 17 '18 at 1:24













          Anyhow, the UI and interface are in a dll which to reference by other program, so that I have to binding the interface to UI and let others to update the UI by creating a new class which inherit the interface. Would you please tell me how I can do this, thank you.

          – 102425074
          Nov 17 '18 at 1:26





          Anyhow, the UI and interface are in a dll which to reference by other program, so that I have to binding the interface to UI and let others to update the UI by creating a new class which inherit the interface. Would you please tell me how I can do this, thank you.

          – 102425074
          Nov 17 '18 at 1:26













          see my edited answer

          – Muzib
          Nov 17 '18 at 7:01





          see my edited answer

          – Muzib
          Nov 17 '18 at 7:01













          Someone told me that I can use an abstract class to do it, I tried but failed. Now I think I can only set a property to the binding and change the property via the class. Thank you.

          – 102425074
          Nov 17 '18 at 13:27





          Someone told me that I can use an abstract class to do it, I tried but failed. Now I think I can only set a property to the binding and change the property via the class. Thank you.

          – 102425074
          Nov 17 '18 at 13:27













          Yes , he/she is right. An abstract class can do that. If you have no problem with abstract classes, then go on.

          – Muzib
          Nov 17 '18 at 14:17





          Yes , he/she is right. An abstract class can do that. If you have no problem with abstract classes, then go on.

          – Muzib
          Nov 17 '18 at 14:17




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53339929%2fwhy-i-cant-update-the-ui-when-binding-a-class-inherits-the-interface%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Xamarin.iOS Cant Deploy on Iphone

          Glorious Revolution

          Dulmage-Mendelsohn matrix decomposition in Python