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

CellTemplate in ResourceDictionary

1 Answer 174 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 20 Mar 2016, 08:31 PM

I tried to move my Grid Columns Content to a separate ResourceDictionary and it works for the first part  the "GridViewDataColumn" not perfectly i expect

but

a) not for the GridViewCheckBoxColumn , do you have a suggestion how to do this ?

b) and 2nd i used the common "TextBox" for the GridViewDataColumn (child control) but which Control should i use if i want the Telerik Standard Control  which is normaly used in the GridView ? if i add

    <t:GridViewDataColumn Header="VALID" ...

    it want work , vs designer tell me that it could not found it

 

thanks br

 

<telerik:GridViewDataColumn Header="XNAME" CellEditTemplate="{StaticResource ClaimListNameDataTemplate}" CellTemplate="{StaticResource ClaimListNameDataTemplate}"/>

<telerik:GridViewCheckBoxColumn Header="VALID" DataMemberBinding="{Binding IsValidYn, Mode=TwoWay}"  AutoSelectOnEdit="True" EditTriggers="CellClick" Width="75*"
                                                CellTemplate="{StaticResource ClaimListValidDataTemplate}" CellEditTemplate="{StaticResource ClaimListValidDataTemplate}"
                                                >
                    <telerik:GridViewCheckBoxColumn.CellStyle >
                        <Style TargetType="telerik:GridViewCell" BasedOn="{StaticResource CenterCheckBoxColumnCellStyle}">
                            <Setter Property="HorizontalContentAlignment" Value="Center" />
                        </Style>
                    </telerik:GridViewCheckBoxColumn.CellStyle>
</telerik:GridViewCheckBoxColumn>

 

IN RESOURCEDIRECTORY

 

 
<ResourceDictionary x:Class="Application.Views.ClaimListResourceDictionary"
                    xmlns:local="clr-namespace:Application.Views"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:t="http://schemas.telerik.com/2008/xaml/presentation"
                    xmlns:tg="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView"
                    >
    <DataTemplate x:Key="ClaimListNameDataTemplate" DataType="{x:Type local:ClaimList}">
        <StackPanel Orientation="Vertical" Background="Brown">
            <Image Height="50" Width="50" HorizontalAlignment="Center" Source="/GapJunctionApplication;component/Images/Refresh2.png"/>
            <TextBox HorizontalAlignment="Stretch" BorderThickness="0" SelectionBrush="Green" BorderBrush="Black" Text="{Binding name_nam, Mode=TwoWay}" TextAlignment="Right"/>
            
        </StackPanel>
    </DataTemplate>

    <DataTemplate x:Key="ClaimListValidDataTemplate" DataType="{x:Type local:ClaimList}">
        ???
    </DataTemplate>

</ResourceDictionary>

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 22 Mar 2016, 10:40 AM
Hi Thomas ,

Generally, by default the GridViewCheckBoxColumn uses a GridViewCheckBox control for the cell in view mode, and a standard MS CheckBox in edit mode. If you need to predefine the template of a particular column, but keep the default one for the rest of the columns, you can benefit from the CellTemplateSelector mechanism. By doing so, you won't need to predefine the templates of all columns.

As to the error you are getting from the designer, I might only be guessing what the cause for it might be. I suggest you taking a look at this, this and this StackOverflow threads for a possible solution. You may also find the Debugging and Interpreting Errors in the WPF Designer.

All the best,
Stefan X1
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Thomas
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or