Welcome to the Xceed Community | Help
Community Search  
More Search Options

Set ContentTemplate at Runtime

Sort Posts: Previous Next
  •  08-25-2009, 11:41 AM Post no. 23512

    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")},

     

    };
    Filed under:
  •  08-25-2009, 11:49 AM Post no. 23513 in reply to 23512

    Re: Set ContentTemplate at Runtime

    Found the Answer:

    DataTemplate
    phoneCellTemplate = this.FindResource("phonenumberCellContentTemplate") as DataTemplate;

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.