Using Itemtemplate in gridview

2 posts, 0 answers
  1. Thnghi
    Thnghi avatar
    9 posts
    Member since:
    Feb 2013

    Posted 01 Jul 2013 Link to this post

    Hi,

    I change GridViewRow template by my custom template like that:
     
    <ControlTemplate x:Key="CustomRowTemplate"
                             TargetType="gridView:GridViewRow">
                <Border x:Name="rowsContainer"
                        Background="Transparent"
                        BorderBrush="{StaticResource BasicBrush}"
    BorderThickness="0,0,0,1"
                        Padding="1">
                    <Grid Width="Auto"
      HorizontalAlignment="Stretch">

                        <Grid.RowDefinitions>
                            <RowDefinition Height="20" />
                            <RowDefinition Height="20" />
                            <RowDefinition Height="20" />
                        </Grid.RowDefinitions>

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition MinWidth="150" Width="Auto" />
                            <ColumnDefinition Width="10" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <Border Grid.Column="0"
    Grid.RowSpan="3"
    Grid.Row="0"
    VerticalAlignment="Center"
    HorizontalAlignment="Stretch"
    Height="60"
    Width="60"
    Margin="15,0"
    BorderThickness="1"
    CornerRadius="1"
    BorderBrush="Black">
                            <Image Source="{Binding Picture, Converter={StaticResource BinaryImageConverter}}"
    HorizontalAlignment="Center"
    VerticalAlignment="Center"></Image>
                        </Border>

                        <TextBlock Text="Device Name: "
    Margin="5,0,0,0"
    FontWeight="Bold"
    Grid.Row="0"
    Grid.Column="1"
    VerticalAlignment="Center"
       HorizontalAlignment="Left" />
                        <TextBlock Text="{Binding SourceDeviceName}"
       Margin="5,0,0,0"
       Grid.Row="0"
       Grid.Column="2"
       VerticalAlignment="Center"
       HorizontalAlignment="Left" />

                        <TextBlock Text="Source: "
       Margin="5,0,0,0"
       FontWeight="Bold"
       Grid.Row="1"
       Grid.Column="1"
       HorizontalAlignment="Left"
       VerticalAlignment="Center" />
                        <TextBlock Text="{Binding SourceId}"
       Margin="5,0,0,0"
       Grid.Row="1"
       Grid.Column="2"
       VerticalAlignment="Center"
       HorizontalAlignment="Left" />

                        <TextBlock Text="Status: "
       Margin="5,0,0,0"
       FontWeight="Bold"
       Grid.Row="2"
       Grid.Column="1"
       HorizontalAlignment="Left"
       VerticalAlignment="Center" />
                        <TextBlock Text="{Binding StatusId}"
       Margin="5,0,0,0"
       Grid.Row="2"
       Grid.Column="2"
       VerticalAlignment="Center"
       HorizontalAlignment="Left" />

                        <Border Grid.Column="3"
    Grid.Row="0"
    Grid.RowSpan="3"
    Width="1"
    Background="{StaticResource BasicBrush}"
    VerticalAlignment="Stretch"
    HorizontalAlignment="Left"
    Margin="0,10" />

                        <TextBlock Text="Vendor: "
       Margin="5,0,0,0"
       FontWeight="Bold"
       Grid.Row="0"
       Grid.Column="4"
       HorizontalAlignment="Left"
       VerticalAlignment="Center" />
                        <TextBlock Text="{Binding VendorId}"
       Margin="5,0,0,0"
       Grid.Row="0"
       Grid.Column="5"
       HorizontalAlignment="Left"
       VerticalAlignment="Center" />

                        <TextBlock Text="Brand: "
       Margin="5,0,0,0"
       FontWeight="Bold"
       Grid.Row="1"
       Grid.Column="4"
       HorizontalAlignment="Left"
       VerticalAlignment="Center" />
                        <TextBlock Text="{Binding Brand}"
       Margin="5,0,0,0"
       Grid.Row="1"
       Grid.Column="5"
       HorizontalAlignment="Left"
       VerticalAlignment="Center" />

                    </Grid>
                </Border>
            </ControlTemplate>
            <Style TargetType="gridView:GridViewRow" BasedOn="{StaticResource GridViewRowStyle}">
                <Setter Property="Template" Value="{StaticResource CustomRowTemplate}" />

            </Style>

    this overites VisualStateManager default and the gridview don't hightlight when mouse over or row selected. 
    I just want to change item template of row and remain style such as: mouse over, slelected.

    I try to use Itemtemplate in radgridview but it doesn't work.

    Can any one help me?
  2. Yoan
    Admin
    Yoan avatar
    1159 posts

    Posted 03 Jul 2013 Link to this post

    Hello Thnghi,

    In order to achieve your goal, I would suggest you to Copy the default style of the GridViewRow and modify it. Please check this help article for a reference.

    Regards,
    Yoan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top