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

Vertival Orientation GridViewImageColumn Cells

3 Answers 100 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Maurizio
Top achievements
Rank 2
Maurizio asked on 02 Nov 2015, 12:44 PM

I'm using a GridViewImageColumn to display images that are smaller than the cell.

How do I change Horizontal Orientation or Vertical Orientation in XAML to let the image appear e.g. on top or on bottom of the cell?

3 Answers, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 03 Nov 2015, 10:11 AM
Hello Peter,

You can create a Style that targets and set the needed properties within it. I am adding a code snippet that I have tested from my side:
<Style x:Key="ImageColumnStyle" TargetType="telerik:GridViewCell">
            <Setter Property="Background" Value="Red"></Setter>
            <Setter Property="HorizontalContentAlignment" Value="Left"></Setter>
            <Setter Property="VerticalContentAlignment" Value="Top"></Setter></Style>

Eventually, you can assign the style to the corresponding GridViewImageColumn through the CellStyle property:
<telerik:GridViewImageColumn  ImageStretch="None"
     DataMemberBinding="{Binding Image}"
     CellStyle="{StaticResource ImageColumnStyle}" >

Peter, please update me if the information provided was useful.

Regards,
Stefan Nenchev
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Maurizio
Top achievements
Rank 2
answered on 03 Nov 2015, 01:29 PM

Thanks Stefan for you reply, but it does not work. I had tried this also already in vain.

 Here is my Style:

    <telerik:RadGridView.Resources>
  <Style x:Key="MyImageColumnStyle" TargetType="telerik:GridViewCell">
      <Setter Property="VerticalContentAlignment" Value="Top"/>
  </Style>
</telerik:RadGridView.Resources>

 And this is my ColumnDefinition:

<telerik:GridViewImageColumn
DataMemberBinding=
"{Binding Level, converter=converter:LoggingLevelToImageSourceConverter}}"
Header="Level" UniqueName="Level"
IsGroupable="False" IsFilterable="False"
ShowFieldFilters="False" ImageWidth="16"
CellStyle="{StaticResource MyImageColumnStyle}" />

 

Though, the image/icon in the cell is not aligned top of the cell (see screenshot). Any ideas?

 

0
Stefan Nenchev
Telerik team
answered on 05 Nov 2015, 05:03 PM
Hi Peter,

I have created a simple project from my end that implements the same approach and setting the HorizontalContentAlignment and VerticalContentAlignment properties seems to do the job. I am also attaching a screenshot and the project itself for you just to check if this is the behavior you need to achieve. 

Peter, would it be possible to send me a sample project from your end as well which I can review and further investigate?

Regards,
Stefan Nenchev
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Maurizio
Top achievements
Rank 2
Answers by
Stefan Nenchev
Telerik team
Maurizio
Top achievements
Rank 2
Share this question
or