AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
26.09k stars 2.26k forks source link

MultiBinding with attached property not working any more #11684

Open flarive opened 1 year ago

flarive commented 1 year ago

Hello,

When i was using AvaloniaUI 0.10.x the following style was working :

<Style Selector="ToggleSwitch:checked:not(.Outline) /template/ Grid#ThumbHolder">
      <Setter Property="RenderTransform">
        <Setter.Value>
          <MultiBinding Converter="{StaticResource WidthToRenderTransformConverter}">
            <Binding Path="(assist:SelectionControlAssist.Size)" RelativeSource="{RelativeSource TemplatedParent}"/>
            <Binding Path="Height" RelativeSource="{RelativeSource TemplatedParent}"/>
          </MultiBinding>
        </Setter.Value>
      </Setter>
    </Style>

SelectionControlAssist.Size is an attached property defined like that :

  public static class SelectionControlAssist
  {
      #region Size of selection widget

      public static AvaloniaProperty<double> SizeProperty
          = AvaloniaProperty.RegisterAttached<Button, double>("Size", typeof(SelectionControlAssist));

      public static double GetSize(Button element) {
          return (double) element.GetValue(SizeProperty);
      }

      public static void SetSize(Button element, double checkBoxSize) {
          element.SetValue(SizeProperty, checkBoxSize);
      }

        #endregion
}

When using 0.11-rc1 i have an exception at runtime :

System.ArgumentException : 'Unable to resolve namespace for type assist:SelectionControlAssist'

à Avalonia.Markup.Xaml.XamlIl.Runtime.XamlIlRuntimeHelpers.XamlTypeResolver.Resolve(String qualifiedTypeName) à Avalonia.Markup.Xaml.Extensions.ResolveType(IServiceProvider ctx, String namespacePrefix, String type) à Avalonia.Markup.Parsers.ExpressionParser.ParseAttachedProperty(AttachedPropertyNameNode node) à Avalonia.Markup.Parsers.ExpressionParser.Parse(CharacterReader& r) à Avalonia.Markup.Parsers.ExpressionObserverBuilder.Parse(String expression, Boolean enableValidation, Func3 typeResolver, INameScope nameScope) à Avalonia.Data.Binding.CreateExpressionObserver(AvaloniaObject target, AvaloniaProperty targetProperty, Object anchor, Boolean enableDataValidation) à Avalonia.Data.BindingBase.Initiate(AvaloniaObject target, AvaloniaProperty targetProperty, Object anchor, Boolean enableDataValidation) à Avalonia.Data.MultiBinding.<>c__DisplayClass37_0.<Initiate>b__0(IBinding x) à System.Linq.Utilities.<>c__DisplayClass2_03.b0(TSource x) à System.Linq.Enumerable.SelectListIterator2.MoveNext() à System.Linq.Enumerable.WhereEnumerableIterator1.ToArray() à Avalonia.Reactive.Operators.CombineLatest2._.Run(IEnumerable1 sources) à Avalonia.Reactive.Operators.CombineLatest2.Subscribe(IObserver1 observer) à Avalonia.Reactive.Observable.<>c__DisplayClass2_0`2.