In the markup there are several elements of the same type that use the same command.

Example:

<Border> <Border.InputBindings> <MouseBinding MouseAction="LeftDoubleClick" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Popup.HideCommand}"/> </Border.InputBindings> </Border> ... <Button Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Popup.HideCommand}" /> 

Is it possible to bind a command to resources and bind to one object already?

  • one
    What's the point? Do you want to shorten anchor text? Instead of stuffing it into resources (I couldn’t think of a working way to do it), you can write your simple markup extension like this: chat.stackexchange.com/transcript/message/40761541#40761541 The code will shrink to the same size as you would would use resources - Andrey NOP
  • @AndreyNOP, Yes, I would like the markup to look less cumbersome. The extension of the markup is good, but then we rest on the fact that we have to set the path from the fixed specified parent. - trydex
  • Well, write 2 markup extensions or 3. C # code is easily rendered into separate small files, unlike XAML markup, which can be simplified much more difficult - Andrey NOP

0