ItemsControl のレイアウト コントロール インスタンス
例
1、ItemsStackPanelの例
Controls/CollectionControl/ItemsControlDemo/LayoutControl/ItemsStackPanelDemo.xaml
<Pagex:Class="Windows10.Controls.CollectionControl.ItemsControlDemo.LayoutControl.ItemsStackPanelDemo"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="using:Windows10.Controls.CollectionControl.ItemsControlDemo.LayoutControl"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"mc:Ignorable="d" xmlns:common="using:Windows10.Common"><Grid Background="Transparent"><StackPanel Margin="10 0 10 10" Orientation="Horizontal"><StackPanel Margin="5"><!--ItemsStackPanel - 虚拟化布局控件,ListView 的默认布局控件 Orientation - 子元素的排列方向 Vertical - 垂直排列,默认值 Horizontal - 水平排列 CacheLength - 可见区外的需要缓存的数据的大小(以可见区条数大小的倍数为单位),默认值为 4.0 比如当可见区可以显示 10 条数据,CacheLength 为 4 时,可见区外的需要缓存的数据的大小则为 4 * 10 = 40,也就是说整个缓存数据的大小为 10 + 4 * 10 = 50 实际测试发现,可能会有一定的偏差,但是大体是准确的--><ListView Name="listView1" Margin="5" Width="400" Height="400" HorizontalAlignment="Left" ItemsSource="{x:Bind MyData.View}"><ListView.ItemTemplate><DataTemplate x:DataType="common:NavigationModel"><Grid Background="Blue"><TextBlock Text="{x:Bind Title}" /></Grid></DataTemplate></ListView.ItemTemplate><ListView.ItemsPanel><ItemsPanelTemplate><ItemsStackPanel Orientation="Vertical" CacheLength="4" /></ItemsPanelTemplate></ListView.ItemsPanel></ListView><TextBlock Name="lblMsg1" Margin="5" /></StackPanel><StackPanel Margin="5"><!--ItemsStackPanel - 虚拟化布局控件,ListView 的默认布局控件 GroupPadding - 每一个数据组的 padding GroupHeaderPlacement - 每一个数据组的 header 的显示位置 Top - 顶部。默认值 Left - 左侧 AreStickyGroupHeadersEnabled - 组 header 是否是固定的,即不随组数据的滚动而滚动。默认值为 true--><ListView Name="listView2" Margin="5" Width="400" Height="400" HorizontalAlignment="Left" ItemsSource="{x:Bind MyData.View}"><ListView.GroupStyle><GroupStyle><GroupStyle.HeaderTemplate><DataTemplate><TextBlock Text="{Binding Title}" /></DataTemplate></GroupStyle.HeaderTemplate></GroupStyle></ListView.GroupStyle><ListView.ItemTemplate><DataTemplate><TextBlock Text="{Binding Title}" /></DataTemplate></ListView.ItemTemplate><ListView.ItemsPanel><ItemsPanelTemplate><ItemsStackPanel GroupPadding="4" GroupHeaderPlacement="Top" AreStickyGroupHeadersEnabled="{Binding IsChecked, ElementName=chkAreStickyGroupHeadersEnabled}" /></ItemsPanelTemplate></ListView.ItemsPanel></ListView><ComboBox x:Name="cmbGroupHeaderPlacement" Margin="5" PlaceholderText="GroupHeaderPlacement" SelectionChanged="cmbGroupHeaderPlacement_SelectionChanged"><ComboBoxItem>Top</ComboBoxItem><ComboBoxItem>Left</ComboBoxItem></ComboBox><CheckBox Name="chkAreStickyGroupHeadersEnabled" Content="AreStickyGroupHeadersEnabled" IsChecked="True" Margin="5" /></StackPanel></StackPanel></Grid></Page>
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(); } } }
2、ItemsWrapGrid の例
Controls/CollectionControl/ItemsControlDemo/LayoutControl/ItemsWrapGridDemo.xaml
<Pagex:Class="Windows10.Controls.CollectionControl.ItemsControlDemo.LayoutControl.ItemsWrapGridDemo"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="using:Windows10.Controls.CollectionControl.ItemsControlDemo.LayoutControl"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"mc:Ignorable="d" xmlns:common="using:Windows10.Common"><Grid Background="Transparent"><StackPanel Margin="10 0 10 10" Orientation="Horizontal"><StackPanel Margin="5"><!--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 Name="gridView1" Margin="5" Width="400" Height="400" HorizontalAlignment="Left" ItemsSource="{x:Bind MyData.View}"><GridView.ItemTemplate><DataTemplate x:DataType="common:NavigationModel"><Grid Background="Blue"><TextBlock Text="{x:Bind Title}" /></Grid></DataTemplate></GridView.ItemTemplate><GridView.ItemsPanel><ItemsPanelTemplate><ItemsWrapGrid Orientation="Horizontal" ItemWidth="120" ItemHeight="50" MaximumRowsOrColumns="3" CacheLength="4" /></ItemsPanelTemplate></GridView.ItemsPanel></GridView><TextBlock Name="lblMsg1" Margin="5" /></StackPanel><StackPanel Margin="5"><!--ItemsWrapGrid - 虚拟化布局控件,GridView 的默认布局控件 GroupPadding - 每一个数据组的 padding GroupHeaderPlacement - 每一个数据组的 header 的显示位置 Top - 顶部。默认值 Left - 左侧 AreStickyGroupHeadersEnabled - 组 header 是否是固定的,即不随组数据的滚动而滚动。默认值为 true--><ListView Name="gridView2" Margin="5" Width="400" Height="400" HorizontalAlignment="Left" ItemsSource="{x:Bind MyData.View}"><ListView.GroupStyle><GroupStyle><GroupStyle.HeaderTemplate><DataTemplate><TextBlock Text="{Binding Title}" /></DataTemplate></GroupStyle.HeaderTemplate></GroupStyle></ListView.GroupStyle><ListView.ItemTemplate><DataTemplate><TextBlock Text="{Binding Title}" Width="100" /></DataTemplate></ListView.ItemTemplate><ListView.ItemsPanel><ItemsPanelTemplate><ItemsWrapGrid Orientation="Horizontal" MaximumRowsOrColumns="3" GroupPadding="4" GroupHeaderPlacement="Top" AreStickyGroupHeadersEnabled="{Binding IsChecked, ElementName=chkAreStickyGroupHeadersEnabled}" /></ItemsPanelTemplate></ListView.ItemsPanel></ListView><ComboBox x:Name="cmbGroupHeaderPlacement" Margin="5" PlaceholderText="GroupHeaderPlacement" SelectionChanged="cmbGroupHeaderPlacement_SelectionChanged"><ComboBoxItem>Top</ComboBoxItem><ComboBoxItem>Left</ComboBoxItem></ComboBox><CheckBox Name="chkAreStickyGroupHeadersEnabled" Content="AreStickyGroupHeadersEnabled" IsChecked="True" Margin="5" /></StackPanel></StackPanel></Grid></Page>
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(); } } }
OK
[ソースコードダウンロード]
以上がItemsControl のレイアウト コントロール インスタンスの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

ホットAIツール

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

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

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

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

人気の記事

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

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

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック









はい、MySQLはWindows 7にインストールできます。MicrosoftはWindows 7のサポートを停止しましたが、MySQLは引き続き互換性があります。ただし、インストールプロセス中に次のポイントに注意する必要があります。WindowsのMySQLインストーラーをダウンロードしてください。 MySQL(コミュニティまたはエンタープライズ)の適切なバージョンを選択します。インストールプロセス中に適切なインストールディレクトリと文字セットを選択します。ルートユーザーパスワードを設定し、適切に保ちます。テストのためにデータベースに接続します。 Windows 7の互換性とセキュリティの問題に注意してください。サポートされているオペレーティングシステムにアップグレードすることをお勧めします。

Slow Photoshopの起動の問題を解決するには、次のような多面的なアプローチが必要です。ハードウェアのアップグレード(メモリ、ソリッドステートドライブ、CPU)。時代遅れまたは互換性のないプラグインのアンインストール。システムのゴミと過剰な背景プログラムを定期的にクリーンアップします。無関係なプログラムを慎重に閉鎖する。起動中に多数のファイルを開くことを避けます。

フロントエンド開発でWindowsのような実装方法...

Photoshopで垂直ガイドを引く:ルーラービューを有効にします(ビュー&gt;ルーラー)。マウスをルーラーの垂直エッジの上にホバリングし、次にカーソルが二重矢印を備えた垂直線になり、マウスを保持してドラッグして基準線を引き出します。ガイドをドラッグして[削除]をクリックするか、クロスにホバリングします。

MySQLのインストールエラーのソリューションは次のとおりです。1。システム環境を慎重に確認して、MySQL依存関係ライブラリの要件が満たされていることを確認します。異なるオペレーティングシステムとバージョンの要件は異なります。 2.エラーメッセージを慎重に読み取り、依存関係のインストールやSUDOコマンドの使用など、プロンプト(ライブラリファイルの欠落やアクセス許可など)に従って対応する測定値を取得します。 3.必要に応じて、ソースコードをインストールし、コンパイルログを慎重に確認してみてください。これには、一定量のLinuxの知識と経験が必要です。最終的に問題を解決する鍵は、システム環境とエラー情報を慎重に確認し、公式の文書を参照することです。

MySQLのインストール障害の主な理由は次のとおりです。1。許可の問題、管理者として実行するか、SUDOコマンドを使用する必要があります。 2。依存関係が欠落しており、関連する開発パッケージをインストールする必要があります。 3.ポート競合では、ポート3306を占めるプログラムを閉じるか、構成ファイルを変更する必要があります。 4.インストールパッケージが破損しているため、整合性をダウンロードして検証する必要があります。 5.環境変数は誤って構成されており、環境変数はオペレーティングシステムに従って正しく構成する必要があります。これらの問題を解決し、各ステップを慎重に確認して、MySQLを正常にインストールします。

端末からmysqlにアクセスできない場合は、次の理由があります。MySQLサービスが実行されていません。接続コマンドエラー;許可が不十分です。ファイアウォールは接続をブロックします。 mysql構成ファイルエラー。

MySQL接続は、次の理由が原因である可能性があります。MySQLサービスは開始されず、ファイアウォールは接続をインターセプトし、ポート番号が間違っています。ユーザー名またはパスワードが間違っています。My.cnfのリスニングアドレスは不適切に構成されています。トラブルシューティング手順には以下が含まれます。 2.ファイアウォール設定を調整して、MySQLがポート3306をリッスンできるようにします。 3.ポート番号が実際のポート番号と一致していることを確認します。 4.ユーザー名とパスワードが正しいかどうかを確認します。 5. my.cnfのバインドアドレス設定が正しいことを確認してください。
