Image Source Converter

2 posts, 0 answers
  1. ITA
    ITA avatar
    383 posts
    Member since:
    Aug 2009

    Posted 24 Oct 2014 Link to this post

    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
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 28 Oct 2014 Link to this post

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top