locked
How do I set ListBox item height in Window Resources? RRS feed

  • Question

  • This

    <ListBox x:Name="gLBxM">
        <ListBox.ItemContainerStyle>
            <Style TargetType="ListBoxItem">
                <Setter Property="Height" Value="21" />
            </Style>
        </ListBox.ItemContainerStyle>
    </ListBox>

    sets the ListBox item height for a specific ListBox. What do add to <Window.Resources> so it applies to all ListBox'es?



    bhs67

    Wednesday, December 4, 2019 2:48 PM

Answers

  • This works:

    <Style TargetType="ListBoxItem">
        <Setter Property="Height" Value="21" />
    </Style>


    bhs67

    • Marked as answer by bhs67 Thursday, December 5, 2019 3:26 PM
    Wednesday, December 4, 2019 6:48 PM

All replies

  • <Style TargetType="{x:Type ListBoxItem}">
        <Setter Property="Height" Value="21"/>
    </Style>


    TR| Sorunuzun yanıtı bu ise "Yanıt Olarak Öner" olarak işaretleyin, eğer faydalı bir yorum ise "Oy Ver"erek forumun işleyişine katkıda bulunabilirsiniz. EN| If this is the answer to your problem, mark "Propose as Answer" and if it is helpful, you can contribute to the workig of the forum by "Voting".

    • Proposed as answer by Alex Li-MSFT Thursday, December 5, 2019 1:17 AM
    Wednesday, December 4, 2019 5:43 PM
  • This works:

    <Style TargetType="ListBoxItem">
        <Setter Property="Height" Value="21" />
    </Style>


    bhs67

    • Marked as answer by bhs67 Thursday, December 5, 2019 3:26 PM
    Wednesday, December 4, 2019 6:48 PM
  • Hi,

    I am glad you have got your solution, please mark the helpful as answer. It will be beneficial to other community.

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, December 5, 2019 1:19 AM