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

[Solved] How to convert this XAML to codebehind

3 Answers 215 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.
Rama
Top achievements
Rank 1
Rama asked on 18 Aug 2010, 02:09 PM
Hi,
    I am using RadGridView and I want to convert the following XAML to codebehind(everthing included from XAML). How can i do that?

<telerikgrid:GridViewDataColumn FooterCellStyle="{StaticResource GridViewFooterCellStyle}" 
        HeaderCellStyle="{StaticResource GridViewHeaderCellStyle}" 

        DataMemberBinding="{Binding Commission.Value,Mode=TwoWay,Converter={StaticResource mConverter}}"
        CellStyleSelector="{StaticResource selecting}">
    <telerikgrid:GridViewDataColumn.Header>
        <StackPanel HorizontalAlignment="Center">
            <TextBlock Text="Net" TextWrapping="Wrap" HorizontalAlignment="Center"/>
            <TextBlock Text="Commission" TextWrapping="Wrap" HorizontalAlignment="Center"/>
        </StackPanel>    
    </telerikgrid:GridViewDataColumn.Header>
    <telerikgrid:GridViewDataColumn.CellTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding Commission.Value,Mode=TwoWay,Converter={StaticResource mConverter}}"
                   FontWeight="{Binding bSubTotalRow, Converter={StaticResource bConverter}}"
                     Foreground="{Binding Commission.IsInvalid,Converter={StaticResource cConverter}}"
                     ToolTipService.ToolTip="{Binding Commission.ValidationText}"/>
            </DataTemplate>
    </telerikgrid:GridViewDataColumn.CellTemplate>
    <telerikgrid:GridViewDataColumn.CellEditTemplate>
        <DataTemplate>
            <TextBox Text="{Binding Commission.Value,Mode=TwoWay}" 
             BorderBrush="{Binding Commission.IsInvalid,Converter={StaticResource cConverter}}"
             ToolTipService.ToolTip="{Binding Commission.ValidationText}"
             IsReadOnly="{Binding bSubTotalRow}"
             TextChanged="DataBoundTextBox_TextChanged"/>
        </DataTemplate>
    </telerikgrid:GridViewDataColumn.CellEditTemplate>
    <telerikgrid:GridViewDataColumn.Footer>
        <TextBlock Text="{Binding Source=StaticResource TotalRow},Mode=TwoWay,
        Path=myCom.Comm,Converter=    {StaticResource vConverter}}"/>

    </telerikgrid:GridViewDataColumn.Footer>
</telerikgrid:GridViewDataColumn>

Thanks.

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 18 Aug 2010, 04:04 PM
Hi,

 You can declare your templates as resources and reuse them when creating the column programmatically. Other possible approach can be found on this blog post

Sincerely yours,
Vlad
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
Rama
Top achievements
Rank 1
answered on 18 Aug 2010, 04:13 PM
Hi Vlad,
    Thank you for your response. I have created "CreateCellElement" , but how do i do binding for footer, tooltipservice, fontweight, foreground, etc? Also, how do i convert CellEditTemplate to codebehind? I cannot find any such examples on your site.

Thanks.
0
Vlad
Telerik team
answered on 19 Aug 2010, 06:17 AM
Hi,

The relevant method for CellEditTemplate is CreateCellEditElement and you can use Header and Footer properties to return desired UI element(s).

All the best,
Vlad
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
Tags
GridView
Asked by
Rama
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Rama
Top achievements
Rank 1
Share this question
or