Vertical center and bolder to each image item

3 posts, 1 answers
  1. Son
    Son avatar
    13 posts
    Member since:
    Sep 2013

    Posted 20 Jan Link to this post

    I want to have a list image as blocks with border.
    I tried using stackpanel or not but i can not set item in ListBoxItem to center.
    ---
    My listbox.ItemsSource is list of bitmapimage converted from base64string in data from web api. So they don't have urls.
    My xaml is in 1.png
    Debug to actual-img.png. I want to have list such as wanted-img.png or wanted-img2.png.
    Can you help me, please?
    ---
    I need click to image, it will show an actual-size image (i can do this) but do you think i should try RadTileList? 
    ---
    Thank you. 
  2. Answer
    Nasko
    Admin
    Nasko avatar
    585 posts

    Posted 22 Jan Link to this post

    Hi Son,

    In order to center the images as expected the VerticalContentAlignment of the ListBoxItems should be set to Center. You could do that from the Style of RadListBoxItem as shown below:
    <Style TargetType="telerik:RadListBoxItem">
        <Setter Property="VerticalContentAlignment" Value="Center"/>
    </Style>

    Thus the images should be displayed in the center as expected. From the Style you could also set the desired brush and thickness of the border:
    <Style TargetType="telerik:RadListBoxItem">
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="BorderBrush" Value="Red"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Margin" Value="2"/>
    </Style>

    Hope this helps.

    Regards,
    Nasko
    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. Son
    Son avatar
    13 posts
    Member since:
    Sep 2013

    Posted 25 Jan in reply to Nasko Link to this post

    Thank you, Nasko. It's exactly what i need. 
Back to Top