CellTemplate in ResourceDictionary

2 posts, 0 answers
  1. Thomas
    Thomas  avatar
    18 posts
    Member since:
    Jun 2012

    Posted 20 Mar Link to this post

    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>

     

     

     

     

  2. Stefan X1
    Admin
    Stefan X1 avatar
    514 posts

    Posted 22 Mar Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top