How to use Canvas as the ItemsPanel for an ItemsControl in Silverlight 3

前端 未结 4 1981
闹比i
闹比i 2021-02-05 22:13

I am trying to set the Canvas properties in an ItemsControl DataTemplate with Silverlight 3. According to this post, the only way of doing that is to set it using the ItemsCont

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-05 22:42

    I'm not sure if it will work in your scenario, but I've accomplished this in the past using the RenderTransform.

    
        
            
                
            
        
        
            
                
                    
                        
                    
                
            
        
        
            10
            30
            50
            70
        
    
    

    Or in the case of binding you will need to use a converter

    
        
            
                
            
        
        
            
                
            
        
        
            10
            30
            50
            70
        
    
    

    Converter

    public void ConvertTo(object value, ...)
    {
        int intValue = int.Parse(value.ToString());
    
        return new TransformGroup()
        {
            Children = new TransformCollection()
            {
                new TranslateTransform { X = intValue, Y = intValue }
            }
        };
    }
    

提交回复
热议问题