Download presentation
Presentation is loading. Please wait.
Published byLynette Newman Modified over 9 years ago
2
Сергей Пугачёв Microsoft MVP @spugachev Silverlight 5, XAML и связывание данных
3
Сделали то, что просили…
4
XAML и связывание данных ImplicitDataTemplates RelativeSource Ancestor Bindings Binding In Style Setters Markup Extensions Databinding Debugging DataContextChanged Event (Post Beta) UpdateSourceTrigger (Post Beta)
5
Implicit Data Templates
6
Шаблоны основаны на типе Учитывается иерархия наследования
7
Relative Source
8
<TextBlock Text="{Binding StateName}" Visibility="{Binding IsDropDownOpen, RelativeSource={RelativeSource FindAncestor AncestorType=ComboBox}, Converter={StaticResource BoolToVisibilityConverter} }"/>
9
Markup Extensions
10
public class MethodInvokeExtension : IMarkupExtension { // Properties Exposed in XAML as Intellisense Love public String Method { get; set; } // Invoked by the XAML Parser @ runtime public object ProvideValue(IServiceProvider serviceProvider) { <UserControl x:Class="AppointmentsView" xmlns:MyUtils="clr-namespace:TestApp;assembly=TestApp">... <ComboBox Name="appointmentsListBox" SelectionChanged="{MyUtils:MethodInvoke Method=OnAppointmentChanged}"
11
Binding Style Setters
12
Создайте класс для представления значений Создайте экземпляр класса в ресурсах Используйте связывание данных в стилях <Setter Property="Foreground" Value="{Binding ForegroundColor, Source={StaticResource MyAppStyles}}"
13
DataContextChanged this.DataContextChanged += View_DataContextChanged; … void View_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { INotifyPropertyChanged customer; customer = e.OldValue as INotifyPropertyChanged; if (customer != null) customer.PropertyChanged -= customer_PropertyChanged; customer = e.NewValue as INotifyPropertyChanged; if (customer != null) customer.PropertyChanged += customer_PropertyChanged; }
14
UpdateSourceTrigger <TextBox Name="vinTextBox" Text="{Binding SelectedClaim.InsuredVIN, Mode=TwoWay}" UpdateSourceTrigger=PropertyChanged}"
15
XAML и связывание данных ImplicitDataTemplates RelativeSource Ancestor Bindings Binding In Style Setters Markup Extensions Databinding Debugging DataContextChanged Event (Post Beta) UpdateSourceTrigger (Post Beta)
16
Сергей Пугачёв Microsoft MVP @spugachev Silverlight 5, XAML и DataBinding
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.