Context menus (and ComboBox dropdowns etc) are instances are Popup
controls that are outside the VisualTree of the hosting control, as you
say. They are handled slightly differently by the WPF framework, but
the DataContext is passed through from the hosting control by default,
meaning all your bindings should would the same as on the hosting
control.
DataGrid columns are a different animal as they are a virtual concept
and don't exist until created by the control. It takes a lot of
plumbing and ancestor lookups to deal with these; it's bloody difficult
to work with them. This is probably the major reason why we make our
own extension; we use some attached properties to gain access to methods
in the DataGrid to work with columns, and spend a lot of time faffing
around with the styling to get what we need.
Fortunately I don't delve much into our ExtendedDataGrid control as it
tends to make whoever works on it go insane and take huge amounts of
leave. *grin*
Carl.
From: [email protected] [mailto:[email protected]]
On Behalf Of Greg Keogh <[email protected]>
Sent: Wednesday, 29 August 2012 9:03 AM
To: "'ozWPF'" <[email protected]>
Subject: RE: ContextMenu command target
Thanks chaps, sorry for the late reply. It turns out I didn't need to
"pass" the command on from the dialog to the main window for this
particular case, but I'm sure I will at some time in the near future and
this issue will return and I'll have to find an elegant way of doing it.
Context menus are general problem in WPF due to their quirks in binding
and commands. I haven't looked into it, but they don't live in the
control tree in the usual way. Same with DataGrid columns and some other
bits and pieces.
Carl, I ran some experiments and removed PlacementTaget from dozens of
my menus and they all continued to work, except some attached to a
ToolBarTray which required this element:
CommandTarget="{Binding Path=PlacementTarget,
RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type
ContextMenu}}}"
So for years now I have assumed that I needed that line on my menus,
probably due to early problems like the one with ToolbarTray, but it
turns out most of them aren't needed. I have globally removed the
unnecessary elements and it's nice to remove XAML clutter. So thanks for
the reminder to look into that issue.
Patrick, what tools/kits are you using to write HTML/JS?
Greg
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud
service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
_______________________________________________
ozwpf mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf
________________________________________________________________________
_______
This email has been scanned by the Bankwest Email Security System.
________________________________________________________________________
_______
_______________________________________________________________________________
Unencrypted electronic mail is not secure and may not be authentic.
If you have any doubts as to the contents please telephone to confirm.
This electronic transmission including any attachments is intended only
for those to whom it is addressed. It may contain copyright material or
information that is confidential, privileged or exempt from disclosure by law.
Any claim to privilege is not waived or lost by reason of mistaken transmission
of this information. If you are not the intended recipient you must not
distribute or copy this transmission and should please notify the sender.
Your costs for doing this will be reimbursed by the sender.
We do not accept liability in connection with computer virus, data corruption,
delay, interruption, unauthorised access or unauthorised amendment.
_______________________________________________________________________________
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
_____________________________________________________________________________________________________________________
ozwpf mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf