locked
Viewbox does not work in Listbox RRS feed

  • Question

  • Hi all,

    Please see my code as below.

    The left Viewbox in Grid works well. But the right Viewbox in listbox does not work.

    What I want is that when resize window and decrease the height of window, then the ico should become smaller and smaller.

    so, how do I make the Viewbox in listbox work?

    <Grid Width="200" HorizontalAlignment="Left">
                <Viewbox Stretch="Uniform" MaxHeight="68">
                    <Image Source="MyIco.ico" MaxHeight="68" />
                </Viewbox>
            </Grid>
            <ListBox Margin="200,0,0,0" ItemsSource="{Binding Students}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled" VerticalContentAlignment="Stretch">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Viewbox Stretch="Uniform" MaxHeight="68">
                            <Image Source="MyIco.ico" MaxHeight="68" />
                        </Viewbox>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

    Thursday, September 10, 2015 8:24 AM

Answers

  • Hi,

    Please set Height to "Auto" in <image>, and check whether it can fix it.

    With regards,

    Angie


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Angie Xu Tuesday, October 6, 2015 8:22 AM
    • Proposed as answer by Angie Xu Tuesday, October 6, 2015 8:22 AM
    • Marked as answer by Angie Xu Friday, October 9, 2015 2:32 AM
    Wednesday, September 16, 2015 8:47 AM