c# - Binding a dynamically created CombinedGeometry Path? -


i have application draws slots on screen rectangles rounded corners. slot can part of section, nothing more collection of slots.

i want visually mark slots have been assigned. draw solid shape covering selected slots.

before selection:

enter image description here

after selection:

enter image description here

the shape has without inner borders, hence combined geometry.

i want bind combinedgeometry datatemplate of selected slots.

viewmodel

    public observablecollection<slot> slots     {         { return _slots; }         set         {             if (equals(value, _slots)) return;             _slots = value;             drawshape();             onpropertychanged();         }     }     private void drawshape()     {         path = new path();         path.stroke = brushes.white;         path.strokethickness = 3;          var count = slots.count();          var combined = new combinedgeometry();         combined.geometrycombinemode = geometrycombinemode.union;          (var = 0; < count; i++)         {             if (i == 0)             {                 var rect1 = new rect(slots[i].positionx, slots[i].positiony, slots[i].width, slots[i].height);                 var rect2 = new rect(slots[i + 1].positionx, slots[i + 1].positiony, slots[i + 1].width,                                      slots[i + 1].height);                 combined.geometry1 = new rectanglegeometry(rect1) { radiusx = 5, radiusy = 5 };                 combined.geometry2 = new rectanglegeometry(rect2) { radiusx = 5, radiusy = 5 };             }             else             {                 var rect = new rect(slots[i + 1].positionx, slots[i + 1].positiony, slots[i + 1].width, slots[i + 1].height);                 combined.geometry1 = combined.clone();                 combined.geometry2 = new rectanglegeometry(rect) { radiusx = 5, radiusy = 5 };             }         }         path.data = combined;     } 

xaml

        <itemscontrol x:name="declaredsections" margin="20" itemssource="{binding path=layout.sections}">             <itemscontrol.itemspanel>                 <itemspaneltemplate>                     <grid/>                 </itemspaneltemplate>             </itemscontrol.itemspanel>             <itemscontrol.itemtemplate>                 <datatemplate>                     <grid>                         <!-- databind combined shape -->                     </grid>                 </datatemplate>             </itemscontrol.itemtemplate>         </itemscontrol> 


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -