例
1、ItemsStackPanelの例
Controls/CollectionControl/ItemsControlDemo/LayoutControl/ItemsStackPanelDemo.xaml
<class><grid><stackpanel><stackpanel><!--ItemsStackPanel - 虚拟化布局控件,ListView 的默认布局控件 Orientation - 子元素的排列方向 Vertical - 垂直排列,默认值 Horizontal - 水平排列 CacheLength - 可见区外的需要缓存的数据的大小(以可见区条数大小的倍数为单位),默认值为 4.0 比如当可见区可以显示 10 条数据,CacheLength 为 4 时,可见区外的需要缓存的数据的大小则为 4 * 10 = 40,也就是说整个缓存数据的大小为 10 + 4 * 10 = 50 实际测试发现,可能会有一定的偏差,但是大体是准确的--><listview><listview.itemtemplate><datatemplate><grid><textblock></textblock></grid></datatemplate></listview.itemtemplate><listview.itemspanel><itemspaneltemplate><itemsstackpanel></itemsstackpanel></itemspaneltemplate></listview.itemspanel></listview><textblock></textblock></stackpanel><stackpanel><!--ItemsStackPanel - 虚拟化布局控件,ListView 的默认布局控件 GroupPadding - 每一个数据组的 padding GroupHeaderPlacement - 每一个数据组的 header 的显示位置 Top - 顶部。默认值 Left - 左侧 AreStickyGroupHeadersEnabled - 组 header 是否是固定的,即不随组数据的滚动而滚动。默认值为 true--><listview><listview.groupstyle><groupstyle><groupstyle.headertemplate><datatemplate><textblock></textblock></datatemplate></groupstyle.headertemplate></groupstyle></listview.groupstyle><listview.itemtemplate><datatemplate><textblock></textblock></datatemplate></listview.itemtemplate><listview.itemspanel><itemspaneltemplate><itemsstackpanel></itemsstackpanel></itemspaneltemplate></listview.itemspanel></listview><combobox><comboboxitem>Top</comboboxitem><comboboxitem>Left</comboboxitem></combobox><checkbox></checkbox></stackpanel></stackpanel></grid></class>
Controls/CollectionControl/ItemsControlDemo/LayoutControl/ItemsStackPanelDemo.xaml.cs
/* * ItemsStackPanel - 虚拟化布局控件,ListView 的默认布局控件(继承自 Panel, 请参见 /Controls/LayoutControl/PanelDemo.xaml) * FirstCacheIndex - 缓存中的第一项在全部数据中的索引位置 * FirstVisibleIndex - 屏幕上显示的第一项在全部数据中的索引位置 * LastCacheIndex - 缓存中的最后一项在全部数据中的索引位置 * LastVisibleIndex - 屏幕上显示的最后一项在全部数据中的索引位置 * CacheLength - 可见区外的需要缓存的数据的大小(以可见区条数大小的倍数为单位),默认值为 4.0 * 比如当可见区可以显示 10 条数据,CacheLength 为 4 时,可见区外的需要缓存的数据的大小则为 4 * 10 = 40,也就是说整个缓存数据的大小为 10 + 4 * 10 = 50 * 实际测试发现,可能会有一定的偏差,但是大体是准确的 */using System;using System.Collections.Generic;using System.Linq;using System.Xml.Linq;using Windows.UI.Xaml;using Windows.UI.Xaml.Controls;using Windows.UI.Xaml.Controls.Primitives;using Windows.UI.Xaml.Data;using Windows10.Common;namespace Windows10.Controls.CollectionControl.ItemsControlDemo.LayoutControl {public sealed partial class ItemsStackPanelDemo : Page {public CollectionViewSource MyData {get{ XElement root = XElement.Load("SiteMap.xml");var items = LoadData(root);// 构造数据源CollectionViewSource source = new CollectionViewSource(); source.IsSourceGrouped = true; source.Source = items; source.ItemsPath = new PropertyPath("Items");return source; } } private ItemsStackPanel _itemsStackPanel1 = null;private ItemsStackPanel _itemsStackPanel2 = null;public ItemsStackPanelDemo() {this.InitializeComponent();this.Loaded += ItemsStackPanelDemo_Loaded; }private void ItemsStackPanelDemo_Loaded(object sender, RoutedEventArgs e) { DispatcherTimer dTimer = new DispatcherTimer(); dTimer.Interval = TimeSpan.Zero; dTimer.Tick += DTimer_Tick; dTimer.Start();// 获取 ListView 中的 ItemsStackPanel 控件_itemsStackPanel1 = listView1.ItemsPanelRoot as ItemsStackPanel; _itemsStackPanel2 = listView2.ItemsPanelRoot as ItemsStackPanel;// 获取 ListView 中的 ItemsStackPanel 控件// _itemsStackPanel1 = Helper.GetVisualChild<itemsstackpanel>(listView1);// _itemsStackPanel2 = Helper.GetVisualChild<itemsstackpanel>(listView2); }private void DTimer_Tick(object sender, object e) { lblMsg1.Text = "FirstCacheIndex: " + _itemsStackPanel1.FirstCacheIndex.ToString(); lblMsg1.Text += Environment.NewLine; lblMsg1.Text += "FirstVisibleIndex: " + _itemsStackPanel1.FirstVisibleIndex.ToString(); lblMsg1.Text += Environment.NewLine; lblMsg1.Text += "LastCacheIndex: " + _itemsStackPanel1.LastCacheIndex.ToString(); lblMsg1.Text += Environment.NewLine; lblMsg1.Text += "LastVisibleIndex: " + _itemsStackPanel1.LastVisibleIndex.ToString(); lblMsg1.Text += Environment.NewLine; lblMsg1.Text += "CacheLength: " + _itemsStackPanel1.CacheLength.ToString(); }private void cmbGroupHeaderPlacement_SelectionChanged(object sender, SelectionChangedEventArgs e) { _itemsStackPanel2.GroupHeaderPlacement = (GroupHeaderPlacement)Enum.Parse(typeof(GroupHeaderPlacement), (e.AddedItems[0] as ComboBoxItem).Content.ToString()); }// 解析 xml 数据private List<navigationmodel> LoadData(XElement root) {if (root == null)return null;var items = from n in root.Elements("node")select new NavigationModel { Title = (string)n.Attribute("title"), Url = (string)n.Attribute("url"), Items = LoadData(n) };return items.ToList(); } } }</navigationmodel></itemsstackpanel></itemsstackpanel>
2、ItemsWrapGrid の例
Controls/CollectionControl/ItemsControlDemo/LayoutControl/ItemsWrapGridDemo.xaml
<class><grid><stackpanel><stackpanel><!--ItemsWrapGrid - 虚拟化布局控件,GridView 的默认布局控件 Orientation - 子元素的排列方向 Vertical - 垂直排列,默认值 Horizontal - 水平排列 ItemWidth - 每个 item 的宽 ItemHeight - 每个 item 的高 MaximumRowsOrColumns - 最大行数或最大列数(默认值为 -1) CacheLength - 可见区外的需要缓存的数据的大小(以可见区条数大小的倍数为单位),默认值为 4.0 比如当可见区可以显示 10 条数据,CacheLength 为 4 时,可见区外的需要缓存的数据的大小则为 4 * 10 = 40,也就是说整个缓存数据的大小为 10 + 4 * 10 = 50 实际测试发现,可能会有一定的偏差,但是大体是准确的--><gridview><gridview.itemtemplate><datatemplate><grid><textblock></textblock></grid></datatemplate></gridview.itemtemplate><gridview.itemspanel><itemspaneltemplate><itemswrapgrid></itemswrapgrid></itemspaneltemplate></gridview.itemspanel></gridview><textblock></textblock></stackpanel><stackpanel><!--ItemsWrapGrid - 虚拟化布局控件,GridView 的默认布局控件 GroupPadding - 每一个数据组的 padding GroupHeaderPlacement - 每一个数据组的 header 的显示位置 Top - 顶部。默认值 Left - 左侧 AreStickyGroupHeadersEnabled - 组 header 是否是固定的,即不随组数据的滚动而滚动。默认值为 true--><listview><listview.groupstyle><groupstyle><groupstyle.headertemplate><datatemplate><textblock></textblock></datatemplate></groupstyle.headertemplate></groupstyle></listview.groupstyle><listview.itemtemplate><datatemplate><textblock></textblock></datatemplate></listview.itemtemplate><listview.itemspanel><itemspaneltemplate><itemswrapgrid></itemswrapgrid></itemspaneltemplate></listview.itemspanel></listview><combobox><comboboxitem>Top</comboboxitem><comboboxitem>Left</comboboxitem></combobox><checkbox></checkbox></stackpanel></stackpanel></grid></class>
Controls/CollectionControl/ItemsControlDemo/LayoutControl/ItemsWrapGridDemo.xaml.cs
/* * ItemsWrapGrid - 虚拟化布局控件,GridView 的默认布局控件(继承自 Panel, 请参见 /Controls/LayoutControl/PanelDemo.xaml) * FirstCacheIndex - 缓存中的第一项在全部数据中的索引位置 * FirstVisibleIndex - 屏幕上显示的第一项在全部数据中的索引位置 * LastCacheIndex - 缓存中的最后一项在全部数据中的索引位置 * LastVisibleIndex - 屏幕上显示的最后一项在全部数据中的索引位置 * CacheLength - 可见区外的需要缓存的数据的大小(以可见区条数大小的倍数为单位),默认值为 4.0 * 比如当可见区可以显示 10 条数据,CacheLength 为 4 时,可见区外的需要缓存的数据的大小则为 4 * 10 = 40,也就是说整个缓存数据的大小为 10 + 4 * 10 = 50 * 实际测试发现,可能会有一定的偏差,但是大体是准确的 */using System;using System.Collections.Generic;using System.Linq;using System.Xml.Linq;using Windows.UI.Xaml;using Windows.UI.Xaml.Controls;using Windows.UI.Xaml.Controls.Primitives;using Windows.UI.Xaml.Data;using Windows10.Common;namespace Windows10.Controls.CollectionControl.ItemsControlDemo.LayoutControl {public sealed partial class ItemsWrapGridDemo : Page {public CollectionViewSource MyData {get{ XElement root = XElement.Load("SiteMap.xml");var items = LoadData(root);// 构造数据源CollectionViewSource source = new CollectionViewSource(); source.IsSourceGrouped = true; source.Source = items; source.ItemsPath = new PropertyPath("Items");return source; } }private ItemsWrapGrid _itemsWrapGrid1 = null;private ItemsWrapGrid _itemsWrapGrid2 = null;public ItemsWrapGridDemo() {this.InitializeComponent();this.Loaded += ItemsWrapGridDemo_Loaded; }private void ItemsWrapGridDemo_Loaded(object sender, RoutedEventArgs e) { DispatcherTimer dTimer = new DispatcherTimer(); dTimer.Interval = TimeSpan.Zero; dTimer.Tick += DTimer_Tick; dTimer.Start();// 获取 GridView 中的 ItemsWrapGrid 控件_itemsWrapGrid1 = gridView1.ItemsPanelRoot as ItemsWrapGrid; _itemsWrapGrid2 = gridView2.ItemsPanelRoot as ItemsWrapGrid;// 获取 GridView 中的 ItemsWrapGrid 控件// _itemsWrapGrid1 = Helper.GetVisualChild<itemswrapgrid>(gridView1);// _itemsWrapGrid2 = Helper.GetVisualChild<itemswrapgrid>(gridView2); }private void DTimer_Tick(object sender, object e) { lblMsg1.Text = "FirstCacheIndex: " + _itemsWrapGrid1.FirstCacheIndex.ToString(); lblMsg1.Text += Environment.NewLine; lblMsg1.Text += "FirstVisibleIndex: " + _itemsWrapGrid1.FirstVisibleIndex.ToString(); lblMsg1.Text += Environment.NewLine; lblMsg1.Text += "LastCacheIndex: " + _itemsWrapGrid1.LastCacheIndex.ToString(); lblMsg1.Text += Environment.NewLine; lblMsg1.Text += "LastVisibleIndex: " + _itemsWrapGrid1.LastVisibleIndex.ToString(); lblMsg1.Text += Environment.NewLine; lblMsg1.Text += "CacheLength: " + _itemsWrapGrid1.CacheLength.ToString(); }private void cmbGroupHeaderPlacement_SelectionChanged(object sender, SelectionChangedEventArgs e) { _itemsWrapGrid2.GroupHeaderPlacement = (GroupHeaderPlacement)Enum.Parse(typeof(GroupHeaderPlacement), (e.AddedItems[0] as ComboBoxItem).Content.ToString()); }// 解析 xml 数据private List<navigationmodel> LoadData(XElement root) {if (root == null)return null;var items = from n in root.Elements("node")select new NavigationModel { Title = (string)n.Attribute("title"), Url = (string)n.Attribute("url"), Items = LoadData(n) };return items.ToList(); } } }</navigationmodel></itemswrapgrid></itemswrapgrid>
OK
[ソースコードダウンロード]
以上がItemsControl のレイアウト コントロール インスタンスの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

C#と.NETランタイムは密接に連携して、開発者に効率的で強力なプラットフォームの開発機能に力を与えます。 1)C#は、.NETフレームワークとシームレスに統合するように設計されたタイプセーフおよびオブジェクト指向のプログラミング言語です。 2).NETランタイムは、C#コードの実行を管理し、ガベージコレクション、タイプの安全性、その他のサービスを提供し、効率的でクロスプラットフォームの操作を保証します。

C#.NET開発を開始するには、次のことが必要です。1。C#の基本的な知識と.NETフレームワークのコア概念を理解する。 2。変数、データ型、制御構造、関数、クラスの基本概念をマスターします。 3。LINQや非同期プログラミングなど、C#の高度な機能を学習します。 4.一般的なエラーのためのデバッグテクニックとパフォーマンス最適化方法に精通してください。これらの手順を使用すると、C#.NETの世界に徐々に浸透し、効率的なアプリケーションを書き込むことができます。

C#と.NETの関係は切り離せませんが、同じものではありません。 C#はプログラミング言語であり、.NETは開発プラットフォームです。 C#は、コードの書き込み、.NETの中間言語(IL)にコンパイルされ、.NET Runtime(CLR)によって実行されるために使用されます。

C#.NETは、複数のアプリケーション開発をサポートする強力なツールとライブラリを提供するため、依然として重要です。 1)C#は.NETフレームワークを組み合わせて、開発を効率的かつ便利にします。 2)C#のタイプの安全性とゴミ収集メカニズムは、その利点を高めます。 3).NETは、クロスプラットフォームの実行環境とリッチAPIを提供し、開発の柔軟性を向上させます。

c#.netisversatileforbothwebanddesktopdevelopment.1)forweb、useasp.netfordynamicapplications.2)fordesktop、equindowsorwpfforrichinterfaces.3)usexamarinforcross-platformdeveliment、enabling deshacrosswindows、

C#と.NETは、継続的な更新と最適化を通じて、新しいテクノロジーのニーズに適応します。 1)C#9.0および.NET5は、レコードタイプとパフォーマンスの最適化を導入します。 2).Netcoreは、クラウドネイティブおよびコンテナ化されたサポートを強化します。 3)ASP.Netcoreは、最新のWebテクノロジーと統合されています。 4)ML.NETは、機械学習と人工知能をサポートしています。 5)非同期プログラミングとベストプラクティスはパフォーマンスを改善します。

c#.netissuitableforenterprise-levelApplicationsとsystemduetoitsSystemdutyping、richlibraries、androbustperformance.

.NETでのC#のプログラミングプロセスには、次の手順が含まれます。1)C#コードの作成、2)中間言語(IL)にコンパイルし、3).NETランタイム(CLR)によって実行される。 .NETのC#の利点は、デスクトップアプリケーションからWebサービスまでのさまざまな開発シナリオに適した、最新の構文、強力なタイプシステム、および.NETフレームワークとの緊密な統合です。


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

Dreamweaver Mac版
ビジュアル Web 開発ツール

mPDF
mPDF は、UTF-8 でエンコードされた HTML から PDF ファイルを生成できる PHP ライブラリです。オリジナルの作者である Ian Back は、Web サイトから「オンザフライ」で PDF ファイルを出力し、さまざまな言語を処理するために mPDF を作成しました。 HTML2FPDF などのオリジナルのスクリプトよりも遅く、Unicode フォントを使用すると生成されるファイルが大きくなりますが、CSS スタイルなどをサポートし、多くの機能強化が施されています。 RTL (アラビア語とヘブライ語) や CJK (中国語、日本語、韓国語) を含むほぼすべての言語をサポートします。ネストされたブロックレベル要素 (P、DIV など) をサポートします。

SublimeText3 中国語版
中国語版、とても使いやすい

WebStorm Mac版
便利なJavaScript開発ツール

MinGW - Minimalist GNU for Windows
このプロジェクトは osdn.net/projects/mingw に移行中です。引き続きそこでフォローしていただけます。 MinGW: GNU Compiler Collection (GCC) のネイティブ Windows ポートであり、ネイティブ Windows アプリケーションを構築するための自由に配布可能なインポート ライブラリとヘッダー ファイルであり、C99 機能をサポートする MSVC ランタイムの拡張機能が含まれています。すべての MinGW ソフトウェアは 64 ビット Windows プラットフォームで実行できます。
