WPF XAML: How to automatically scale down children of a component in XAML?

后端 未结 2 971
时光说笑
时光说笑 2020-12-22 12:44

Here\'s my problem:

xaml file 1: a templated list control


   

        
相关标签:
2条回答
  • 2020-12-22 12:54

    Yeah Set VerticalStretch for your repeating element to Stretch, that should automatically make them behave as part of the list.

    As for the list, if it blows out of your container, put it in a Dockpanel.

    Sorry I couldn't understand what you're doing with the scale transform :) ... but it does sound like hammering a screw in.

    Maybe post a screenshot if that doesn't do it to help us understand.

    0 讨论(0)
  • 2020-12-22 13:04

    I believe a Viewbox will do what you want. It has a single child which is always given its desired size, and it applies a ScaleTransform to the child so that it fits inside the Viewbox. By default it will apply a uniform stretch, but you can change this by setting the Stretch property.

    Something like this:

    <ItemsControl ItemsSource="{Binding myUIrelatedDataList}">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <Viewbox Width="160" Height="80">
                    <my:DynamicUIPresenter />
                </Viewbox>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
    
    0 讨论(0)
提交回复
热议问题