Passing Guid to IMultiValueConverter
-
05-07-2021 - |
Question
I've created a multivalueconverter that I'm binding a telerik:RadMenuItem's visibility property. This right-click menu is inside of an appointment that goes onto a Telerik calendar control. I want to pass the ControlID (which is an attached property from the framework I'm using) into the IMultiValueConverter that I've made as a parameter. So, I want to pass in the Guid (which comes in as the second value in an object array in the converter) and then cast it something to get the value so I can do my evaluations. WPF isn't my strong suit and after trying a lot of things I can't seem to get the binding wired up.
<telerik:RadMenuItem Header="Cancel" x:Name="CancelMenuItem"
Click="RadMenuItemCancel_Click"
myframework:BaseWindow.ControlID="e5c25731-e30e-472e-a5d7-ab190348a7cb">
<telerik:RadMenuItem.Visibility>
<MultiBinding Converter="{StaticResource SecurityEnumToVisibilityConverter}">
<Binding Path="Appointment.AppointmentType" />
<Binding ElementName="CancelMenuItem" Path="myframework:BaseWindow.ControlID" />
</MultiBinding>
</telerik:RadMenuItem.Visibility>
</telerik:RadMenuItem>
What am I missing here in that second Binding tag to pass in the contents of ControlID to my multivalue converter successfully? Thanks!
Solution
Try surrounding your path with brackets.
Path="(myframework:BaseWindow.ControlID)"
afaik this tells WPF that you are binding to an attached property