C# WrapPanel Items控件引用原始集合中的单个项
我正在制作一个房地产管理程序,在主页上,我在C# WrapPanel Items控件引用原始集合中的单个项,c#,wpf,data-binding,event-handling,itemscontrol,C#,Wpf,Data Binding,Event Handling,Itemscontrol,我正在制作一个房地产管理程序,在主页上,我在WrapPanel中列出了所有类似的属性: 现在,即使每个属性都完全相同,也只是用于演示和测试多个属性。每个属性都是ObservableCollection属性中不同的属性对象(很抱歉名称混淆),如下面我的c#代码所示: public ObservableCollection<Property> Properties { get; set; } // ... Property defaultProperty = new Propert
WrapPanel
中列出了所有类似的属性:
现在,即使每个属性都完全相同,也只是用于演示和测试多个属性。每个属性都是ObservableCollection属性中不同的属性
对象(很抱歉名称混淆),如下面我的c#代码所示:
public ObservableCollection<Property> Properties { get; set; }
// ...
Property defaultProperty = new Property(/*Lots of Stuff*/);
properties.Add(defaultProperty);
properties.Add(defaultProperty);
properties.Add(defaultProperty);
properties.Add(defaultProperty);
properties.Add(defaultProperty);
Properties = properties;
publicobservableCollection属性{get;set;}
// ...
Property defaultProperty=新属性(/*很多东西*/);
添加(defaultProperty);
添加(defaultProperty);
添加(defaultProperty);
添加(defaultProperty);
添加(defaultProperty);
属性=属性;
这些属性(Properties属性的一部分(再次抱歉))随后通过itemscontrol显示,如下所示:
<ItemsControl x:Name="wPanel" ItemsSource="{Binding Properties}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel x:Name="PropertyPanel" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Margin="5,5,5,5" BorderBrush="Red" BorderThickness="1" HorizontalAlignment="Left" VerticalAlignment="Top">
<Grid MinWidth="350" MouseLeftButtonUp="Grid_MouseLeftButtonUp">
// Column and Row Definitions
// ...
// Three other corners of the grid
<StackPanel Grid.Row="1" Grid.Column="1" VerticalAlignment="Bottom">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="5,5,5,0" MouseLeftButtonDown="IssuesPanel_MouseLeftButtonDown" > // <-- This is the part I'm trying to get to work
<TextBlock Text="{Binding IssuesNum}" VerticalAlignment="Center"/>
<TextBlock Text=" Issues " VerticalAlignment="Center"/>
<Image VerticalAlignment="Center">
<Image.Source>
<BitmapImage UriSource="/VentureVisions;component/warning.png" DecodePixelWidth="18" />
</Image.Source>
</Image>
</StackPanel>
</StackPanel>
</Grid>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
//列和行定义
// ...
//网格的其他三个角
//从表面上看,这是用几种不同的口味来回答的,请参考以下主题:
希望这些能有所帮助
为了进一步帮助您,如果您正在使用任何级别的数据绑定,那么您可以简单地将“问题”图像交互绑定到“viewmodel”上的命令,在您的实例中,viewmodel将是属性对象。您知道一种不使用mvvm术语的方法吗?我想深入研究一下,但到目前为止我还没有在这个项目中使用过,所以。。。如果我能保持原样那就太好了。我环顾四周,最后找到了你的一页。我花了一段时间才明白它是如何适合我的问题的。但确实如此。谢谢