slide1
Download
Skip this Video
Download Presentation
Сергей Пугачёв Microsoft MVP @ spugachev

Loading in 2 Seconds...

play fullscreen
1 / 17

Сергей Пугачёв Microsoft MVP @ spugachev - PowerPoint PPT Presentation


  • 101 Views
  • Uploaded on

Silverlight 5 , XAML и связывание данных. Сергей Пугачёв Microsoft MVP @ spugachev. Сделали то , что просили…. XAML и связывание данных. ImplicitDataTemplates RelativeSource Ancestor Bindings Binding In Style Setters Markup Extensions Databinding Debugging

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Сергей Пугачёв Microsoft MVP @ spugachev' - ranae


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
slide2

Silverlight 5, XAML и связывание данных

Сергей ПугачёвMicrosoft MVP

@spugachev

slide4
XAML и связывание данных
  • ImplicitDataTemplates
  • RelativeSource Ancestor Bindings
  • Binding In Style Setters
  • Markup Extensions
  • DatabindingDebugging
  • DataContextChangedEvent (Post Beta)
  • UpdateSourceTrigger(Post Beta)
implicit data templates
Implicit Data Templates
  • Шаблоны основаны на типе
  • Учитывается иерархия

наследования

<ListBoxItemsSource="{BindingVehicles}"/>

<Application.Resources>

<ResourceDictionary>

<!--Default Vehicle DataTemplate-->

<DataTemplateDataType="models:Vehicle">

<Image Source="Vehicle.png"/>

</DataTemplate>

<DataTemplateDataType="models:Car">

<Image Source="Car.png"/>

</DataTemplate>

<DataTemplateDataType="models:Truck">

<Image Source="Truck.png"/>

</DataTemplate>

<DataTemplateDataType="models:Motorcycle">

<Image Source="Motorcycle.png"/>

</DataTemplate>

</ResourceDictionary>

</Application.Resources>

relative source
Relative Source

<DataTemplate x:Key="StateComboBoxDataTemplate">

<StackPanel Orientation="Horizontal">

<TextBlock Text="{BindingStateCode}"Margin="0,0,5,0"/>

<TextBlock Text="{BindingStateName}"

Visibility="{BindingIsDropDownOpen,

RelativeSource={RelativeSourceFindAncestor

AncestorType=ComboBox},

Converter={StaticResourceBoolToVisibilityConverter}}"/>

</StackPanel>

markup extensions
Markup Extensions

publicclassMethodInvokeExtension: IMarkupExtension<object> {

// Properties Exposed in XAML as Intellisense Love

publicStringMethod { get; set; }

// Invoked by the XAML Parser @ runtime

publicobjectProvideValue(IServiceProviderserviceProvider) {

<UserControl x:Class="AppointmentsView"

xmlns:MyUtils="clr-namespace:TestApp;assembly=TestApp">

...

<StackPanel x:Name="LayoutRoot">

<ComboBox Name="appointmentsListBox"

SelectionChanged="{MyUtils:MethodInvoke Method=OnAppointmentChanged}"

binding style setters
Binding Style Setters
  • Создайте класс для представления значений
  • Создайте экземпляр класса в ресурсах
  • Используйте связывание данных в стилях

namespaceMyProject.Styles {

publicclassMyAppStyles: INotifyPropertyChanged{

publicBrushForegroundColor{

get{ return _foregroundColor; }

set { _foregroundColor = value;

NotifyPropertyChanged("ForegroundColor");

<ResourceDictionaryxmlns:stylesNS="clr-namespace:MyProject.Styles">

<stylesNS:MyAppStyles x:Key="MyAppStyles"/>

<StyleTargetType="TextBlock">

<Setter Property="Foreground"

Value="{BindingForegroundColor, Source={StaticResourceMyAppStyles}}"

datacontextchanged

Coming Soon

post beta

DataContextChanged

this.DataContextChanged += View_DataContextChanged;

voidView_DataContextChanged(objectsender, DependencyPropertyChangedEventArgs e) {

INotifyPropertyChanged customer;

customer = e.OldValueasINotifyPropertyChanged;

if (customer != null)

customer.PropertyChanged -= customer_PropertyChanged;

customer = e.NewValueasINotifyPropertyChanged;

if (customer != null)

customer.PropertyChanged += customer_PropertyChanged;

}

updatesourcetrigger

Coming Soon

post beta

UpdateSourceTrigger

<TextBox Name="vinTextBox"

Text="{BindingSelectedClaim.InsuredVIN, Mode=TwoWay}"

UpdateSourceTrigger=PropertyChanged}"

slide15
XAML и связывание данных
  • ImplicitDataTemplates
  • RelativeSource Ancestor Bindings
  • Binding In Style Setters
  • Markup Extensions
  • DatabindingDebugging
  • DataContextChangedEvent (Post Beta)
  • UpdateSourceTrigger(Post Beta)
slide16

Silverlight 5, XAML и DataBinding

Сергей ПугачёвMicrosoft MVP

@spugachev

ad