(1)前端篇

首先,我们创建一个新的Universal Windows Platform程序。这些小方块是通过GridView来罗列的,这样可以避免MainPaga.xaml的<Rectangle>元素堆叠太多,并且也好处理数据。

现在我们来看MainPage.xaml到底应该怎么写。

 <Grid Background="Black">
<StackPanel Orientation="Vertical">
<GridView Width="1400" Height="730" x:Name="GridView" Margin="0,20,0,0">
<GridView.ItemTemplate>
<DataTemplate>
<Rectangle Width="50" Height="50" Fill="{Binding Color}"/>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
<Button Height="40" Width="200" Content="寻路" Background="CadetBlue" HorizontalAlignment="Center" BorderBrush="CadetBlue" Click="ButtonBase_OnClick"/>
</StackPanel>
</Grid>
 <Rectangle Width="50" Height="50" Fill="{Binding Color}"/>

就是地图的地砖啦~

 GridView.ItemsSource = Rects;

这里的ItemSource我在C#的后端再进行绑定。

==========================

怎么做到寻路的时候更新地形呢?

首先我考虑到可不可以用ObservableCollection呢?

答案是:不可行!因为ObservableCollection<T>只关注个数的变化,不关注元素的修改。

那怎么做呢?

 GridView.ItemsSource = null;
GridView.ItemsSource = Rects;

取消绑定再重新绑定就可以了!

最新文章

  1. Configure the Windows Firewall to Allow SQL Server Access
  2. [转]解决a different object with the same identifier value was already associated with the session错误
  3. ExtJs6.0.0随笔
  4. 写个PHP框架吧
  5. ASCII编码表
  6. Windows 10 Java环境变量配置
  7. Oracle中synonym和index
  8. Intellij idea使用postgresql 反向生成实例, &#39;Basic&#39; attribute type should not be &#39;Object&#39;
  9. HDU 4280 Island Transport(网络流)
  10. ASP.net button类控件click事件中传递参数
  11. c++ complie link error 2019/2001
  12. [转] JavaScript 之 ArrayBuffer
  13. Mysql for Linux安装配置之—— rpm(bundle)安装
  14. Event.target和Event.currentTarget的区别
  15. Ehcache缓存配置和基本使用
  16. 解决shell命令&quot;** is not in the sudoers file...&quot;错误
  17. ipmitool命令详解
  18. python多线程的使用
  19. 让vs IIS Express支持本地静态Json文件
  20. Android程序员学WEB前端(2)-HTML(2)-锚点链接列表表单-Sublime

热门文章

  1. Primer回顾 数组和指针
  2. 《精通Spring4.X企业应用开发实战》读后感第五章(Bean作用域)
  3. Sharepoint2013搜索学习笔记之创建搜索服务(二)
  4. ABP 软删除ISoftDelete
  5. 2014-9-27 NOIP模拟赛
  6. LeetCode.8-字符串转整数(String to Integer (atoi))
  7. linux查看系统版本(适用于centos、ubutun,其他类型没有进行测试)
  8. CSS3 - CheakBox 开关效果
  9. JS中比较的数值如何比较大小
  10. c#基础2-out-ref