Hi,
I am using Silverlight 4 in C# with Infragistics' web client package. What I am trying to do is to create a control template for a cell's style in a XamGrid control. Inside the control template, there is a TextBlock control which is used to display the cell's value.
I have successfully adding a TextBlock in the control template. However, when I was trying to assign the cell's value to the Text property of the TextBlock control by setting Text={TemplateBinding Cell.Value}, I got an error saying Value was nout found. If I set Text={TemplateBinding Content}, there was nothing displayed in the TextBlock control.
I am wondering how to bind the Text property of the TextBlock control to the cell's value.
Thank you for your response.
Best,
Frank
Hi Frank,
What exactly are you trying to do?
Why aren't you using a TextColumn, or if you're trying to bind to custom values, why aren't you using a TemplateColumn or UnboundColumn?
-SteveZ
Hi Stephen,
Thank you for getting back to me so quickly.
I am working on a small project which allows a user to enter a number, say 5, in a text box, then a XamGrid will automatically create the entered number, 5, of columns. The header of the columns must be underlined, so must be the cells in the grid, and all of the texts have red foreground color and right text alignment.
When I tried to use TextColumn to implement this functionality (because it has TextBlockStyle, through which I can easily set the underline for the texts), I found that I must assign each text column a unique key, which represents a property of a data object that the grid is bound to. The first difficulty I encountered was that I couldn't fully define all data objects that could be used as the ItemSource since my application allows the user to enter any number he wants. So, I came up with a solution to this problem. I defined a data object with just one property, and when filling out the property of the data object, each value is separated by a delimiter. In the example above, when the user enters 5 in the text box, the grid should create 5 columns. Instead of having to define in advance a data object that has 5 properties and assign a value to each of these 5 properties, I just instantiate an instance of the data object that has only one property, combine the 5 values with 4 delimiter into a single string, and assign the string to the only property of the data object. Regarding displaying the data, I add 5 unbound columns to the grid, and add a value conver to each of them, which parses the string and displaying the corresponding part of the string. By doing so, the grid can display any number of columns without having to define unlimited number of data objects first.
However, by using the unbound columns, I can't have the text displayed underlined. So, I am thinking about designing a control template that has a TextBlock to display a cell's data and assign the control template to the unbound columns. By doing so, I expect I can set foreground, text alignment, and underline very easily.
The question is then, how can I get a cell's value and have it displayed in the Text property of the TextBlock?
I am new to everything from Silverlight to Infragistics' package. So, I welcome any suggestions to my delimma.
Thank you very much.