如何将 WrapPanel 中的所有项目宽度设置为相同的值?

发布于 2024-09-29 08:05:48 字数 129 浏览 0 评论 0原文

据我所知,有一些属性允许使 WrapPanel 中的每个元素具有相同的宽度(ShareSizeScope)。现在我想在 silverlight 中实现相同的输出,但没有这样的属性。是否有任何属性或其他方法可以帮助我获得与 WPF 中相同的输出?

As I know there are some properties that allow to make every elements in WrapPanel have same width (ShareSizeScope). Now I want to archieve the same output in silverlight but there's no such property. Are there any properties or other ways that can help me to get same output as in WPF?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瘫痪情歌 2024-10-06 08:05:48

目前,控件中没有等效的命令来完成此操作。我不确定您的需求是什么,但如果是我,我会将面板中每个控件的宽度绑定到具有正确宽度的东西。在此示例中,我在页面上有宽度为 200 的示例控件,然后我将所有 WrapPanel 子项设置为匹配该控件,无论它是什么。

    <Grid x:Name="LayoutRoot" Background="White">
    <TextBlock x:Name="MyTarget" Text="Hello World" Width="200"/>
    <toolkit:WrapPanel Name="wrapPanel1" Margin="0,30">
        <TextBlock Text="The" Width="{Binding ElementName=MyTarget, Path=Width}" />
        <TextBlock Text="Quick" Width="{Binding ElementName=MyTarget, Path=Width}"/>
        <TextBlock Text="Brown" Width="{Binding ElementName=MyTarget, Path=Width}"/>
        <TextBlock Text="Fox" Width="{Binding ElementName=MyTarget, Path=Width}"/>
        <TextBlock Text="Jumped" Width="{Binding ElementName=MyTarget, Path=Width}"/>
        <TextBlock Text="Over" Width="{Binding ElementName=MyTarget, Path=Width}"/>
        <TextBlock Text="The" Width="{Binding ElementName=MyTarget, Path=Width}"/>
        <TextBlock Text="Lazy" Width="{Binding ElementName=MyTarget, Path=Width}"/>
        <TextBlock Text="Dog" Width="{Binding ElementName=MyTarget, Path=Width}"/>
    </toolkit:WrapPanel>
</Grid>

At the moment, there is no equivalent command in the control to accomplish this. I'm not sure what your needs are, but if it were me, I'd bind the width of each control in the panel either to something that has the right width. In this example, I have sample control on the page that is 200 in width, then I set all the WrapPanel children to match that, whatever it is.

    <Grid x:Name="LayoutRoot" Background="White">
    <TextBlock x:Name="MyTarget" Text="Hello World" Width="200"/>
    <toolkit:WrapPanel Name="wrapPanel1" Margin="0,30">
        <TextBlock Text="The" Width="{Binding ElementName=MyTarget, Path=Width}" />
        <TextBlock Text="Quick" Width="{Binding ElementName=MyTarget, Path=Width}"/>
        <TextBlock Text="Brown" Width="{Binding ElementName=MyTarget, Path=Width}"/>
        <TextBlock Text="Fox" Width="{Binding ElementName=MyTarget, Path=Width}"/>
        <TextBlock Text="Jumped" Width="{Binding ElementName=MyTarget, Path=Width}"/>
        <TextBlock Text="Over" Width="{Binding ElementName=MyTarget, Path=Width}"/>
        <TextBlock Text="The" Width="{Binding ElementName=MyTarget, Path=Width}"/>
        <TextBlock Text="Lazy" Width="{Binding ElementName=MyTarget, Path=Width}"/>
        <TextBlock Text="Dog" Width="{Binding ElementName=MyTarget, Path=Width}"/>
    </toolkit:WrapPanel>
</Grid>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文