TransWikia.com

about IComponentConnector2

Stack Overflow Asked by yushang on December 22, 2021

I have the following code

struct MainPage : PageT<MainPage,IComponentConnector,IComponentConnector2>
{...}

How GetBindingConnector get called? As a comparison, I know if I set the ConnectionId attribute on the Xaml page, IComponentConnector.Connect will get called. So there must exist some attribute(s) that will trigger GetBindingConnector, then what’s that? Many thanks!!!

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Button Content="Test" x:ConnectionId="1"/>
</Page>

New Update

1,Using x:Bind and GetBindingConnector called

<Page
    x:Class="BlankApp1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:BlankApp1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Button x:Name="myButton" Content="{x:Bind MyProperty}"/>
</Page>

and the dump of xbf

PushScopeAddNamespace (prefix=(null), namespace=http://schemas.microsoft.com/winfx/2006/xaml/presentation)
  AddNamespace (prefix=x, namespace=http://schemas.microsoft.com/winfx/2006/xaml)
  AddNamespace (prefix=local, namespace=using:BlankApp1)
  AddNamespace (prefix=d, namespace=http://schemas.microsoft.com/expression/blend/2008)
  AddNamespace (prefix=mc, namespace=http://schemas.openxmlformats.org/markup-compatibility/2006)
  CreateTypeBeginInit (type=Windows.UI.Xaml.Controls.Page)
  SetConnectionId (Id=type=Signed, value=1)
  CheckPeerType (x:Class=BlankApp1.MainPage)
  PushScopeCreateTypeBeginInit (type=Windows.UI.Xaml.Controls.Button)
    SetConnectionId (Id=type=Signed, value=2)
    SetName (x:Name=myButton)
  EndInitPopScope
  SetValue (property=Windows.UI.Xaml.Controls.UserControl.Content)
EndInitPopScope

2, Not using x:Bind:

<Page
    x:Class="BlankApp1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:BlankApp1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Button x:Name="myButton"/>
</Page>

and the dump of xbf

PushScopeAddNamespace (prefix=(null), namespace=http://schemas.microsoft.com/winfx/2006/xaml/presentation)
  AddNamespace (prefix=x, namespace=http://schemas.microsoft.com/winfx/2006/xaml)
  AddNamespace (prefix=local, namespace=using:BlankApp1)
  AddNamespace (prefix=d, namespace=http://schemas.microsoft.com/expression/blend/2008)
  AddNamespace (prefix=mc, namespace=http://schemas.openxmlformats.org/markup-compatibility/2006)
  CheckPeerType (x:Class=BlankApp1.MainPage)
  CreateTypeBeginInit (type=Windows.UI.Xaml.Controls.Page)
  PushScopeCreateTypeBeginInit (type=Windows.UI.Xaml.Controls.Button)
    SetConnectionId (Id=type=Signed, value=2)
    SetName (x:Name=myButton)
  EndInitPopScope
  SetValue (property=Windows.UI.Xaml.Controls.UserControl.Content)
EndInitPopScope

3, differences of the 2 dumps
enter image description here

I’m not sure if this is the root cause that makes difference.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP