WPF开发工具的使用帮助我们实现了许多以前难以实现的图形处理功能。我们在这里将会为大家介绍一下有关WPF嵌入式资源的相关概念。#t#
WPF嵌入式资源代码示例:
- < Page x:Class="WpfWebApp.Page1"
- xmlns="http://schemas.microsoft.
com/winfx/2006/xaml/presentation" - xmlns:uc="clr-namespace:
WpfLibruary;assembly=WpfLibruary" - xmlns:x="http://schemas.microsoft.
com/winfx/2006/xaml" - xmlns:local="clr-namespace:WpfWebApp"
- Title="Page1" Height="332"
Width="757" VerticalAlignment="Top"> - < Page.Resources>
- < local:PersonCollection x:Key="PersonC">
- < local:Person Id="1" Name="Cgc1" />
- < local:Person Id="2" Name="Cgc2" />
- < local:Person Id="3" Name="Cgc3" />
- < /local:PersonCollection>
- < /Page.Resources>
- < Grid Height="289">
- < TextBlock FontSize="24"
TextWrapping="Wrap" Margin=
"0,0,0,-19.998"> - < Hyperlink x:Name="LnkPre"
NavigateUri="Page2.xaml"
Foreground="Black"> - Enter Page2
- < /Hyperlink>
- < /TextBlock>
- < Button Margin="358,43,214,0"
Name="button1" Click="button1_Click"
Height="49.024" VerticalAlignment
="Top">Button< /Button> - < ListBox ItemsSource="{StaticResource
PersonC}" IsSynchronizedWithCurrentItem
="True" x:Name="LstPerson"
HorizontalAlignment="Left"
Width="297" Height="131"
VerticalAlignment="Top"> - < ListBox.ItemTemplate>
- < DataTemplate>
- < DockPanel>
- < TextBlock Text="{Binding
Path=Id}">< /TextBlock> - < TextBlock Text="分分:">< /TextBlock>
- < TextBlock Text="{Binding
Path=Name}">< /TextBlock> - < /DockPanel>
- < /DataTemplate>
- < /ListBox.ItemTemplate>
- < /ListBox>
- < /Grid>
- < /Page>
- public class Person
- {
- public Person()
- { }
- public Person(Int32 Id, String Name)
- {
- this.Id = Id;
- this.Name = Name;
- }
- public Int32 Id
- {
- get;
- set;
- }
- public String Name
- {
- get;
- set;
- }
- }
- public class PersonCollection :
System.Collections.ObjectModel.
ObservableCollection< Person> - {
- }
WPF嵌入式资源的相关概念就为大家介绍这里。