This is a migrated thread and some comments may be shown as answers.

[Solved] Silverlight Grid inside cell

5 Answers 69 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Samuel
Top achievements
Rank 1
Samuel asked on 11 Nov 2010, 09:13 PM
How can I insert a Grid in a cell? I've tried the following with no success.

<telerik:RadGridView ItemsSource="{Binding ListClass1, Mode=TwoWay}" AutoGenerateColumns="False">
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn Width="100" DataMemberbinding="{Binding Grid1}" Header="Símbolo" IsFilterable="False" />
        <telerik:GridViewDataColumn Width="*" DataMemberBinding="{Binding String1}" Header="Valor" IsFilterable="False" />
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

Do I need to change the CellTemplate?

Thanks.

5 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 12 Nov 2010, 08:55 AM
Hi Samuel,

Basically, if you want to define a specific element inside the cell, you need to set either CellTemplate or CellEditTemplate, depending on your requirements. However, the code-snippet you post does not provide me with enough information about your goal. So, please share more details on the topic in order for me to be able to suggest any further.

Regards,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Samuel
Top achievements
Rank 1
answered on 12 Nov 2010, 01:49 PM
In this case, what I want is to insert a rectangle shape inside a cell, but I will surely need to insert a lot of other complex or group of shapes in the Silverlight grid to fill the cell of the GridView:

private ObservableCollection<Category> listCategory;
 
public ObservableCollection<Category> ListCategory;
{
    get
    {
        return listCategory;
    }
}
 
//...
 
public class Category
{
    public Category()
    {
        firstCell = new Grid();
        firstCell.Children.Add(new Rectangle()
        {
            Width = 8,
            Height = 17,
            Fill = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0))
        });
         
        secondCell = "string test";
    }
 
    private Grid firstCell;
    private string secondCell;
     
    public Grid FirstCell
    {
        get
        {
            return firstCell;
        }
 
        set
        {
            firstCell = value;
        }
    }
     
    public string SecondCell
    {
        get
        {
            return secondCell;
        }
 
        set
        {
            secondCell = value;
        }
    }
}

And that's the XAML:
<telerik:RadGridView  ItemsSource="{Binding ListCategory}" AutoGenerateColumns="False">
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn Width="100" DataMemberbinding="{Binding FirstCell}" Header="Column 1" IsFilterable="False" />
        <telerik:GridViewDataColumn Width="*" DataMemberBinding="{Binding SecondCell}" Header="Column 2" IsFilterable="False" />
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

What do I need to do to achieve this?
0
Maya
Telerik team
answered on 12 Nov 2010, 05:27 PM
Hi Samuel,

You may define your Templates in the xaml file and then define them inside the CellTemplate of a particular column. Let me know if you need any further assistance.
 

Best wishes,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Samuel
Top achievements
Rank 1
answered on 12 Nov 2010, 06:12 PM
So it is not possible to change the cell dinamically (create shape programmatically)?
0
Maya
Telerik team
answered on 16 Nov 2010, 05:47 PM
Hello Samuel,

I am not quite sure about the purpose of your attempt to change cell dynamically. What is the exact behavior you want to achieve ? As mentioned previously, you may work with the CellTemplate of a particular column and define the element you want to display inside.
 

Kind regards,
Maya
the Telerik team
See What's New in RadControls for Silverlight in Q3 2010 on Tuesday, November 16, 2010 11:00 AM - 12:00 PM EST or 10:00 PM - 11:00 PM EST: Register here>>
Tags
GridView
Asked by
Samuel
Top achievements
Rank 1
Answers by
Maya
Telerik team
Samuel
Top achievements
Rank 1
Share this question
or