0

I hava a User control and in that user control one button.

On click on that button i need to pass the entire view through command paramter.

How can i pass the view through command paramter?

vkshibu
  • 31
  • 5

1 Answers1

0

If I remember the right way (and you want to bind to your current Window instance), it should be

CommandParameter="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}}"

See: How do I use WPF bindings with RelativeSource?

Community
  • 1
  • 1
Felix C
  • 1,755
  • 5
  • 26
  • 40
  • Will provide the datacontext and it will not provide the view details "{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" – vkshibu Apr 16 '13 at 10:23
  • Sorry, I don't understand you. Do you want to bind to the view (type of Window / UserControl) or to the DataContext of your view? – Felix C Apr 16 '13 at 10:37
  • You could also set x:Name="myView" on the View and use {Binding ElementName=myView}. Is easier than RelativeSource, but shouldn't be used if your View is the top level element of a XAML file. – hbarck Apr 16 '13 at 12:17