0
votes

i'm new to wpf , i need to place a tow different drawing inside an item-controls items according to a specific binding value ,

the item control is for this case a button with a canvas in its content i need to render the drawing onto the canvas after performing a check on the bounded value

the item control is bounded to an ObservableCollection of Employee's

The Data Template is as follows (just the relative properties)

   <Button>
        <Grid>
            <ViewBox>
                  <Canvas>
                        <!-- Here go some shapes that -->
                  </Canvas>
              </ViewBox>         
        </Grid>
   </Button>

my question is , how to go about rendering the shapes through the Binding source i thought about a converter which would manually add the shapes from code behind but i cant figure out which of the canvas's properties to Bind .

any idea's would be appreciated.

1

1 Answers

2
votes

You ca use the Canvas.Children property. You can place each single element by calling Canvas.SetTop(), Canvas.SetLeft() on each shape. I agree that some custom converter can do the job you want.