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

Image Source Converter

1 Answer 126 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ITA
Top achievements
Rank 1
ITA asked on 24 Oct 2014, 02:22 PM
Hi,

i have to change the image of a GridViewCell dynamically.

<local:ImageDayConverter x:Key="DayConverter" />
        <Style x:Key="CellStyle" TargetType="{x:Type telerik:GridViewCell}">
            <Setter Property="Background" Value="red" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="BorderBrush" Value="{x:Null}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Border BorderBrush="#f2f2f2" BorderThickness="0,0,0,2" Padding="0,5,0,5">
                            <StackPanel Orientation="Horizontal">
                                <Image Height="30" Source="{Binding DayImage, Converter={StaticResource DayConverter}}"/>
                                <StackPanel Orientation="Vertical" Margin="10,0,0,0" VerticalAlignment="Top">
                                    <TextBlock Text="{Binding Titel}" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="{Binding Start}" Foreground="#9fa2ae"/>
                                        <TextBlock Text=" - " />
                                        <TextBlock Text="{Binding Startzeit}" Foreground="#9fa2ae" />
                                    </StackPanel>
                                </StackPanel>
                            </StackPanel>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

This is my Image:
<Image Height="30" Source="{Binding DayImage, Converter={StaticResource DayConverter}}"/>

How must the Converter look like? The Value of DayImage is a string "10,10,2014"

Thanks a lot
Best Regards
Rene

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 28 Oct 2014, 08:12 AM
Hello Rene,

I would suggest you to specify CellTemplate directly on GridViewColumn instead. You can also check the following article in our online documentation suggesting how to do so: Setting CellTemplate and CellEditTemplate.
Then, you can apply a CellTemplateSelector.

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
ITA
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or