Search code examples
xamluwp-xamlinkcanvas

Can't set InkToolbarRulerButton background as transparent using InkToolbar


I create a ink toolbar, and the initial controls are all except pens. I can set the eraser button's background as transparent, but apply to the ruler button. Is this a ink toolbar bug?

<InkToolbar Background="Transparent" InitialControls="AllExceptPens" TargetInkCanvas="{x:Bind inkCanvas}">
      <InkToolbarEraserButton Background="Transparent"/>
      <InkToolbarRulerButton Background="Transparent"/>
</InkToolbar>

enter image description here


Solution

  • The rule button is actually the InkToolbarStencilButton in the visual tree, not InkToolbarRulerButton. So that update your code snippet as follows will work.

    <InkToolbar
        Background="Transparent"
        InitialControls="AllExceptPens" 
        <InkToolbarEraserButton Background="Red" />
        <!--<InkToolbarRulerButton Background="Red" Foreground="Blue"   />-->
        <InkToolbarStencilButton Background="Red"></InkToolbarStencilButton>
    </InkToolbar>