Vertival Orientation GridViewImageColumn Cells

4 posts, 0 answers
  1. Maurizio
    Maurizio avatar
    43 posts
    Member since:
    Jan 2012

    Posted 02 Nov 2015 Link to this post

    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?

  2. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    277 posts

    Posted 03 Nov 2015 Link to this post

    Hello Peter,

    You can create a Style that targets "telerik:GridViewCell" 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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Maurizio
    Maurizio avatar
    43 posts
    Member since:
    Jan 2012

    Posted 03 Nov 2015 in reply to Stefan Nenchev Link to this post

    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?

     

  5. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    277 posts

    Posted 05 Nov 2015 Link to this post

    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
Back to Top