English 中文(简体)
WPF - 建立一个彩色网
原标题:WPF - create a grid of colors

我对世界森林论坛的看法是这样:

public class SwatchViewModel
{
    public ObservableCollection<Color> Colors { get; private set; }
}

我想在收集过程中展示每一种颜色,放在一栏中。 每一栏次都应占用相同数量的控制空间,所有栏目都应填充控制区。 这种控制可能是任意的。

因此,如果<代码>Colors contained{> Colors. Red, Colors。 Green, Colors。 然后,我需要三栏,每栏占控制区块的三分之一,每个栏目都适当。

这样做的最佳方式是什么? 这似乎适用于<代码>ItemsControl。 页: 1 项目Control does items items 补 页: 1 Grid,但电离层柱可能受约束。

XAML是首选的,尽管我很乐于在必要时回到C#。

最佳回答

您可使用<代码>UniformGrid。 统一的网格符合你的需要,它根据它所包含的儿童数量增加了电池。

例:

<ItemsControl ItemsSource="..." ItemTemplate="...">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <UniformGrid Rows="1"/>
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
</ItemsControl>

。 将浏览量限制在1(duh...)。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签