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

Image Bind with

2 Answers 303 Views
GridView
This is a migrated thread and some comments may be shown as answers.
aryz
Top achievements
Rank 1
aryz asked on 12 Oct 2010, 11:27 AM
Hi All ,
I need advise and guide, i have difficult dealing with radgridview (wpf), i want to bind a column image with dynamic path value,  the images is stored in "[solutionpath]/Resources/Images/", I wonder why i have a message that the path is not found.
Assumed bind value for image path is "../Resources/Images/icon.jpg".

I have these piece of code :
<Grid x:Name="LayoutRoot" Background="White">
    <Grid.Resources>                                               
        <local:KPI_Diff_Style x:Key="_DiffStyle" >
            <local:KPI_Diff_Style.UpStyle>
                <Style TargetType="telerik:GridViewCell">
                    <Setter Property="Background" Value="Red"/>                                                        
                </Style>           
            </local:KPI_Diff_Style.UpStyle>        
            <local:KPI_Diff_Style.DownStyle>
                <Style TargetType="telerik:GridViewCell">
                    <Setter Property="Background" Value="Yellow"/>             
                </Style>           
            </local:KPI_Diff_Style.DownStyle>        
            <local:KPI_Diff_Style.EqStyle>
                <Style TargetType="telerik:GridViewCell">
                    <Setter Property="Background" Value="Green"/>              
                </Style>           
            </local:KPI_Diff_Style.EqStyle>        
        </local:KPI_Diff_Style>
    </Grid.Resources>
    <telerik:RadGridView x:Name="gridKPI" CanUserFreezeColumns="False" ItemsSource="{Binding}" ShowGroupPanel="False" GridLinesVisibility="Horizontal" AutoGenerateColumns="False">
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding KPINameDisplay}" Header="KPI Trends" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding KPIName}" Header="KPI Name" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding MapKPIColumnName}" Header="KPI Column Name" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding StartDate}" Header="Start Date" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding EndDate}" Header="End Date" />
            <telerik:GridViewImageColumn DataMemberBinding="{Binding ImageUpDown}" Header="Difference" ImageStretch="None" CellStyleSelector="{StaticResource _DiffStyle}" MinWidth="5" />                                                 
            <telerik:GridViewDataColumn DataMemberBinding="{Binding ImageView}" Header="View" >
                <telerik:GridViewDataColumn.CellTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">                                                               
                            <Button Content="View Details" />                                                              
                        </StackPanel>
                    </DataTemplate>
                </telerik:GridViewDataColumn.CellTemplate>
            </telerik:GridViewDataColumn>
        </telerik:RadGridView.Columns>
    </telerik:RadGridView>
</Grid>

Thanks

2 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 13 Oct 2010, 02:54 PM
Hi Aryz,

Using your code snippet I am not able to understand how the Build Action of your image is set. I have prepared an example for you that creates a dynamic image binding in RadGridView. In my case I set the Build Action property of the Image to Content, rather that to Resource, Copy to output Directory is set to always and the image is shown, respecting the same image path.

Please check the attached file and if you need any further assistance please let me know.

Kind regards,
Vanya Pavlova
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
aryz
Top achievements
Rank 1
answered on 14 Oct 2010, 06:40 AM
great example vanya thanks .
Tags
GridView
Asked by
aryz
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
aryz
Top achievements
Rank 1
Share this question
or