Set ContentTemplate at Runtime
-
-
Jason
-
-
-
Joined on 08-20-2009
-
-
Posts 7
-
-
|
Set ContentTemplate at Runtime
We have a generic grid that is loaded with Columns at runtime. However I need to set the content template of items such as phone numbers. Is it possible to define the datatemplate in XAML then use it in the codebeind?
<!-- XAML ->
<local:PhoneNumberConverter x:Key="PhoneConverter" />
<DataTemplate x:Key="phonenumberCellContentTemplate"> <TextBlock Text="{Binding Converter={StaticResource PhoneConverter}}" /> </DataTemplate>
<!-- CODE BEHIND -->
Column[] columns = {new Column() { Title = "Phone", FieldName="Phone1", ReadOnly=true, Width=50, CellContentTemplate = new DataTemplate("phonenumberCellContentTemplate")},
};
|
|
-
-
Jason
-
-
-
Joined on 08-20-2009
-
-
Posts 7
-
-
|
Re: Set ContentTemplate at Runtime
Found the Answer:
DataTemplate phoneCellTemplate = this.FindResource("phonenumberCellContentTemplate") as DataTemplate;
|
|
|
|
|
|