@@ -509,31 +509,37 @@ namespace AdaptiveCards::Rendering::Xaml_Rendering::ActionHelpers
509509 auto button = CreateButton (action);
510510 button.Content (elementToWrap);
511511
512- uint32_t cardPadding = 0 ;
513- if (fullWidth)
514- {
515- cardPadding = hostConfig.Spacing ().Padding ();
516- }
512+ auto hostConfigImpl = peek_innards<winrt::implementation::AdaptiveHostConfig>(hostConfig);
513+ auto addSelectActionMargin = hostConfigImpl->AddSelectActionMargin ();
517514
518- // We want the hit target to equally split the vertical space above and below the current item.
519- // However, all we know is the spacing of the current item, which only applies to the spacing above.
520- // We don't know what the spacing of the NEXT element will be, so we can't calculate the correct spacing
521- // below. For now, we'll simply assume the bottom spacing is the same as the top. NOTE: Only apply spacings
522- // (padding, margin) for adaptive card elements to avoid adding spacings to card-level selectAction.
523- if (adaptiveCardElement)
515+ if (addSelectActionMargin)
524516 {
525- auto elementSpacing = adaptiveCardElement.Spacing ();
526- uint32_t spacingSize = GetSpacingSizeFromSpacing (hostConfig, elementSpacing);
517+ uint32_t cardPadding = 0 ;
518+ if (fullWidth)
519+ {
520+ cardPadding = hostConfig.Spacing ().Padding ();
521+ }
522+
523+ // We want the hit target to equally split the vertical space above and below the current item.
524+ // However, all we know is the spacing of the current item, which only applies to the spacing above.
525+ // We don't know what the spacing of the NEXT element will be, so we can't calculate the correct spacing
526+ // below. For now, we'll simply assume the bottom spacing is the same as the top. NOTE: Only apply spacings
527+ // (padding, margin) for adaptive card elements to avoid adding spacings to card-level selectAction.
528+ if (adaptiveCardElement)
529+ {
530+ auto elementSpacing = adaptiveCardElement.Spacing ();
531+ uint32_t spacingSize = GetSpacingSizeFromSpacing (hostConfig, elementSpacing);
527532
528- double topBottomPadding = spacingSize / 2.0 ;
533+ double topBottomPadding = spacingSize / 2.0 ;
529534
530- // For button padding, we apply the cardPadding and topBottomPadding (and then we negate these in the margin)
531- button.Padding ({(double )cardPadding, topBottomPadding, (double )cardPadding, topBottomPadding});
535+ // For button padding, we apply the cardPadding and topBottomPadding (and then we negate these in the margin)
536+ button.Padding ({(double )cardPadding, topBottomPadding, (double )cardPadding, topBottomPadding});
532537
533- double negativeCardMargin = cardPadding * -1.0 ;
534- double negativeTopBottomMargin = topBottomPadding * -1.0 ;
538+ double negativeCardMargin = cardPadding * -1.0 ;
539+ double negativeTopBottomMargin = topBottomPadding * -1.0 ;
535540
536- button.Margin ({negativeCardMargin, negativeTopBottomMargin, negativeCardMargin, negativeTopBottomMargin});
541+ button.Margin ({negativeCardMargin, negativeTopBottomMargin, negativeCardMargin, negativeTopBottomMargin});
542+ }
537543 }
538544
539545 // Style the hit target button
0 commit comments