xaml文件代碼如下:
<Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="660"> <Grid> <Grid.Resources> <Style x:Key="styledItems" TargetType="{x:Type ListBox}"> <Setter Property="ItemTemplate"> <Setter.Value> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" SharedSizeGroup="MiddleColumn" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="60" /> </Grid.RowDefinitions> <Border Margin="4,0" Grid.Column="2" BorderThickness="2" CornerRadius="4"> <Border.BorderBrush> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <GradientStop Color="#aaa" Offset="0" /> <GradientStop Color="#222" Offset="1" /> </LinearGradientBrush> </Border.BorderBrush> <Grid> <Rectangle> <Rectangle.Fill> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <GradientStop Color="#444" Offset="0" /> <GradientStop Color="#fff" Offset="1" /> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> <Image Width="48" Margin="2,2,2,1" Source="{Binding ImagePath}" /> </Grid> </Border> <TextBlock FontSize="16" VerticalAlignment="Center" Margin="5" FontStyle="Italic">User:</TextBlock> <TextBlock FontSize="16" VerticalAlignment="Center" Margin="5" Text="{Binding Name}" FontWeight="Bold" Grid.Column="1" /> </Grid> </DataTemplate> </Setter.Value> </Setter> <Setter Property="Grid.IsSharedSizeScope" Value="True" /> </Style> <Style x:Key="styledList1" TargetType="{x:Type ListBox}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ListBox}"> <Border Background="{TemplateBinding Panel.Background}" BorderBrush="{TemplateBinding Border.BorderBrush}" BorderThickness="{TemplateBinding Border.BorderThickness}"> <ScrollViewer HorizontalScrollBarVisibility="Auto"> <StackPanel x:Name="StackPanel1" IsItemsHost="True" Orientation="Horizontal"/> </ScrollViewer> </Border> </ControlTemplate> </Setter.Value> </Setter> <Setter Property="VerticalAlignment" Value="Center" /> <Setter Property="ItemTemplate"> <Setter.Value> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="60" /> <RowDefinition Height="30" /> </Grid.RowDefinitions> <Border Margin="4,0" Grid.Column="0" BorderThickness="2" CornerRadius="4" HorizontalAlignment="Center"> <Border.BorderBrush> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <GradientStop Color="#aaa" Offset="0" /> <GradientStop Color="#222" Offset="1" /> </LinearGradientBrush> </Border.BorderBrush> <Grid> <Rectangle> <Rectangle.Fill> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <GradientStop Color="#444" Offset="0" /> <GradientStop Color="#fff" Offset="1" /> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> <Image Width="48" Margin="2,2,2,1" Source="{Binding ImagePath}" /> </Grid> </Border> <TextBlock Grid.Row="1" FontSize="14" HorizontalAlignment="Center" Margin="5" Text="{Binding Name}" FontWeight="Bold"/> </Grid> </DataTemplate> </Setter.Value> </Setter> <Setter Property="Grid.IsSharedSizeScope" Value="True" /> </Style> <Style x:Key="styledList2" TargetType="{x:Type ListBox}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ListBox}"> <Border Background="{TemplateBinding Panel.Background}" BorderBrush="{TemplateBinding Border.BorderBrush}" BorderThickness="{TemplateBinding Border.BorderThickness}"> <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled"> <WrapPanel IsItemsHost="True" /> </ScrollViewer> </Border> </ControlTemplate> </Setter.Value> </Setter> <Setter Property="ItemTemplate"> <Setter.Value> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="140" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="60" /> <RowDefinition Height="30" /> </Grid.RowDefinitions> <Border Margin="4,0" Grid.Column="0" BorderThickness="2" CornerRadius="4" HorizontalAlignment="Center"> <Border.BorderBrush> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <GradientStop Color="#aaa" Offset="0" /> <GradientStop Color="#222" Offset="1" /> </LinearGradientBrush> </Border.BorderBrush> <Grid> <Rectangle> <Rectangle.Fill> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <GradientStop Color="#444" Offset="0" /> <GradientStop Color="#fff" Offset="1" /> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> <Image Width="48" Margin="2,2,2,1" Source="{Binding ImagePath}" /> </Grid> </Border> <TextBlock Grid.Row="1" FontSize="14" HorizontalAlignment="Center" Margin="5" Text="{Binding Name}" /> </Grid> </DataTemplate> </Setter.Value> </Setter> <Setter Property="Grid.IsSharedSizeScope" Value="True" /> </Style> </Grid.Resources> <ListBox ItemsSource="{Binding}" Style="{StaticResource styledItems}" Margin="27,22,40,13" Name="listBox1"> </ListBox> </Grid> </Window>
第一種Style的效果:
第二種Style的效果:
第三種Style的效果
對應cs文件爲:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using ListBoxStyling; namespace WpfApplication1 { /// <summary> /// Window1.xaml的代碼 /// </summary> public partial class Window1 : Window { public Window1() { InitializeComponent(); DataContext = UserInfo.Users; } } }
UserInfo.cs文件代碼爲:
using System; using System.Collections.Generic; using System.Text; using System.Windows.Media; namespace ListBoxStyling { public class UserInfo { private string nameVal; public string Name { get { return nameVal; } set { nameVal = value; } } private string imagePathVal; public string ImagePath { get { return imagePathVal; } set { imagePathVal = value; } } public override string ToString() { return Name; } public UserInfo(string name, string imagePath) { this.nameVal = name; this.imagePathVal = imagePath; } public static UserInfo[] Users = { new UserInfo("Arthur Alfredsen", "Images/airplane.bmp"), new UserInfo("Brenda Barret", "Images/astro.bmp"), new UserInfo("Carl Christiansen", "Images/beach.bmp"), new UserInfo("Delia Davis", "Images/butterfl.bmp"), new UserInfo("Egbert Evesham", "Images/car.bmp"), new UserInfo("Fenella Ferguson", "Images/cat.bmp"), new UserInfo("Graham Garden", "Images/chess.bmp"), new UserInfo("Hilary Humperdinck", "Images/dirtbike.bmp"), new UserInfo("Ian Ingernook", "Images/dog.bmp"), new UserInfo("Joan Jackson", "Images/drip.bmp"), new UserInfo("Kevin Kostco", "Images/duck.bmp"), new UserInfo("Leah Limbert", "Images/fish.bmp"), new UserInfo("Marvin Masterson", "Images/frog.bmp"), new UserInfo("Nellie Norbert", "Images/guitar.bmp"), new UserInfo("Ollie Ogilvy", "Images/horses.bmp"), new UserInfo("Priscilla Peters", "Images/kick.bmp"), new UserInfo("Quentin Quasires", "Images/liftoff.bmp"), new UserInfo("Roberta Roberts", "Images/palmtree.bmp"), new UserInfo("Steve Stuart", "Images/pnkflowr.bmp"), new UserInfo("Teri Tobeson", "Images/redflowr.bmp"), new UserInfo("Ulysses Uhura", "Images/skater.bmp"), new UserInfo("Val Vignette", "Images/snwflake.bmp"), new UserInfo("William Watson", "Images/drip.bmp"), new UserInfo("Xanthe Xardos", "Images/user.bmp"), new UserInfo("Ybrahim Yavin", "Images/guest.bmp"), new UserInfo("Zaphod Zacharzewski", "images/soccer.bmp") }; } }
最近Virtualbox虛擬機經常卡頓、鼠標無法點擊,給工作帶來很多麻煩。有一次身子在開會的時候直接卡死,特別尷尬。。 一開始以爲是輸入法或者操作系統補丁的問題,但調整後並不能解決。 更改虛擬機的各種設置,全部無效。 之後升級了Virt
比特幣採用Pow共識機制,即不斷調整Nonce值,對區塊頭做雙重SHA256哈希運算,使得結果滿足給定數量前導0的哈希值的過程。其中前導0的個數,取決於挖礦難度,前導0的個數越多,挖礦難度越大。 1 塊兒產生時的檢查 首先,生成鑄幣交易,並
插件原理回顧 在前面,我們通過 MyBatis插件機制介紹與原理 分析了 MyBatis 插件的基本原理,但是可能還只是理論上的分析,沒有實戰的鍛鍊可能理解的還是不夠透徹。接下來,我們通過自定義插件實例來進一步深度理解 MyBatis 插件
繼上一篇文章在.NET Core,除了VB的LikeString,還有其它方法嗎?(四種LikeString實現分享)分享了四種實現方式,筆者對這四種實現方式,不管是執行性能還是內存分配性能上,都不太滿意。 那麼是否有好的實現方法呢?答案是
1.繼承Thread類 2.實現Runnable接口 因爲Runnable接口就是支持函數式編程的接口,可以這麼玩 3.實現Callable接口,用FutureTask<T>獲取返回值。FutureTask還是繼承的Runn
前言: 首先要知道什麼是線程池? 池化:數據庫連接池, 線程池,字符串常量池 線程是用來執行任務的, 如果不用線程池,那麼線程每次使用前創建,使用後釋放,資源利用率低。所以說用線程池提高了線程對象利用率。 所以可以用線程池完成,先創建好那麼
實驗環境 原理 生成kube-vip靜態pod配置清單 export VIP=192.168.215.200 # 我的vip是192.168.215.200 export INTERFACE=ens33 #可以用 ip a 查看接口名稱
前言 使用 Keyboard Maestro 做自動化管理是,Actions太多了,總是記不住,這裏特意記錄一下 正文 觸發鍵盤按鍵 Type a Keystroke Categories: Interface Control Action
前言 今天大姚給大家分享一款.NET開源(MIT License)、免費、跨平臺、功能強大的繪圖庫,支持多平臺使用(包括:WPF、UWP、WinForm、Silverlight、Xamarin.iOS、Xamarin.Android、Xam
前言 算法在計算機科學和程序設計中扮演着至關重要的角色,如在解決問題、優化效率、決策優化、實現計算機程序、提高可靠性以及促進科學融合等方面具有廣泛而深遠的影響。今天大姚給大家分享一個開源、免費、全面的C#算法實戰教程:TheAlgorith
筆記本沒顯卡. 玩黑魂1, 不是重置版還可以. 裝上受死版之後, 需要打dsfix 的補丁. 設置: DSfix.ini # internal rendering resolution of the game # higher values
C語言--右移 左移 右移,高位補符號位,低位移除(正整數符號位爲0,負整數符號位爲1) 16 >> 2 等價爲 16 /( 2 * 2) 左移,高位移除,低位補零,最高位爲1時,表示負數。16 << 2 等價爲 16 *( 2 * 2)
一、緩存雪崩、緩存穿透 現象:緩存雪崩:大量緩存同時過期、緩存中間件宕機 緩存穿透:訪問不存在key、緩存過期解決:緩存雪崩:設置不同過期時間 緩存穿透:不存在key也存入緩存、使用布隆過濾器、使用分佈式
在使用HbuilderX,使用vue3開發uniapp時,我運行app,報錯,rollup組件找不到了。這個rollup是一個編譯js的工具,win32-x64的意思是採用windows版本64位的運行版本,msvc是說,需要windows