wpf - Bind adorner property to viewmodel property -
I need to display an adorner (or not) based on the view modal's property.
My thoughts are like this:
& amp; Item: control ol x: name = "item" & gt; & Lt; ItemsControl.ItemsPanel & gt; & Lt; ItemsPanelTemplate & gt; & Lt; Canvas / & gt; & Lt; / ItemsPanelTemplate & gt; & Lt; /ItemsControl.ItemsPanel> & Lt; ItemsControl.ItemContainerStyle & gt; & Lt; Style TargetType = "ContentPresenter" & gt; & Lt; Setter Property = "canvas.lift" value = "{binding path = X}" /> & Lt; Setter property = "canvas.Tap" value = "{binding path = y}" /> & Lt; Setter property = "width" value = "{binding path = width}" /> & Lt; Setter property = "height" value = "{binding path = height}" /> & Lt; / Style & gt; & Lt; /ItemsControl.ItemContainerStyle> & Lt; ItemsControl.ItemTemplate & gt; & Lt; DataTemplate & gt; & Lt; AdornerDecorator & gt; & Lt; Border x: name = "dragableborder" background = "{binding path = background color}" & gt; & Lt ;! - content - & gt; & Lt; I: Interaction.Behaviors & gt; & Lt; Behavior: drag oncanvivas Beavier draggableItem = "{binding}" & gt; & Lt; Behavior: DragOnCanvasBehavior.MouseOverAdornerTemplate & gt; & Lt; DataTemplate & gt; & Lt; Border data kontex = "dragableborder" borderbrush = "# b 20000000" width = "{binding path = width}" height = "{binding path = altitude}" /> & Lt; / DataTemplate & gt; & Lt; / Behavior: DragOnCanvasBehavior.MouseOverAdornerTemplate & gt; & Lt; Behavior: DragOnCanvasBehavior.SelectedAdornerTemplate & gt; & Lt; DataTemplate & gt; & Lt; Border DataContext = "DraggableBorder" BorderBrush = "# FF34619E" Width = "{Binding Path = width}" height = "{binding path = height}" visibility = "{binding path = selected, elementname = dragableborder, converter = {static resource BooleanTovability Convention}} "/> & Lt; / DataTemplate & gt; & Lt; / Behavior: DragOnCanvasBehavior.SelectedAdornerTemplate & gt; & Lt; / Behavior: DragOnCanvasBehavior & gt; & Lt; / I: Interaction.Behaviors & gt; & Lt; / Border & gt; & Lt; / AdornerDecorator & gt; & Lt; / DataTemplate & gt; & Lt; /ItemsControl.ItemTemplate> & Lt; / ItemsControl> And the behavior connects the mouse events appropriately, and shows / shows the mouse on the adorner.
Mouse over / out events and advertisers are working fine, but due to selection, I became the cause of the problem. Because only one item should be selected, I want to rely on the view model's selected property, I think what happens in the above sample (I tried some versions), but alas, It is not.
How do I write my visibility property?
Visibility binding binds to a property with 'selected' dragableborder, Which is not in existence.
In addition, there is a datacentext = "dragableborder" in the border, in which case, there is a simple string.
Your limit:
& lt; Border data contact = "{binding data contexts, elementname = dragableborder}" Visibility = "{binning selected, converter = ...}" />
Comments
Post a Comment