bcis 4650 visual programming for business applications n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
BCIS 4650 Visual Programming for Business Applications PowerPoint Presentation
Download Presentation
BCIS 4650 Visual Programming for Business Applications

Loading in 2 Seconds...

play fullscreen
1 / 37

BCIS 4650 Visual Programming for Business Applications - PowerPoint PPT Presentation


  • 125 Views
  • Uploaded on

BCIS 4650 Visual Programming for Business Applications. Data Binding. Additional Information re Text Formatting. Markup Extensions. Markup Extension & Syntax. Is a XAML technique for supplying complex values or values that do not map to a type; uses { }

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 'BCIS 4650 Visual Programming for Business Applications' - raven-barker


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
bcis 4650 visual programming for business applications

BCIS 4650 Visual Programming for Business Applications

Data Binding

The University of North Texas, ITDS Dept., Dr. Vedder

markup extension syntax
Markup Extension & Syntax
  • Is a XAML technique for supplying complex values or values that do not map to a type; uses { }
  • Can be pre-defined in XAML (x:Type, x:Null, etc.), WPF, or Windows (WPF – Windows Presentation Foundation – is part of .NET and renders UI; current version 4.5)
  • Can be custom-defined

The University of North Texas, ITDS Dept., Dr. Vedder

wpf specific markup extensions most often used
WPF-Specific Markup Extensions *= most often used
  • *StaticResource: lookup a value pre-defined elsewhere
  • *DynamicResource: for runtime values
  • *Binding: data-bound; complex syntax
  • RelativeSource: for sources that can change according to runtime conditions

The University of North Texas, ITDS Dept., Dr. Vedder

wpf specific markup extensions 2
WPF-Specific Markup Extensions, 2
  • TemplateBinding: source is a template
  • ColorConvertedBitmap: adv. imaging
  • ComponentResourceKey: resource data is packaged with a custom control
  • ThemeResource: theme data is packaged with a custom control

The University of North Texas, ITDS Dept., Dr. Vedder

resource
Resource
  • An object whose property values can be used repeatedly in an app
  • Typically defined (XAML or C#) on page or in app, but can be defined elsewhere
  • Must have a key (string name) to access
  • Examples:
    • Brushes (for painting color, graphics)
    • Styles

The University of North Texas, ITDS Dept., Dr. Vedder

lookup behavior for the key
Lookup Behavior for the Key
  • Page (i.e., <Page.Resources>)
  • App (ex., App.xaml, MyResources.xaml)
  • Available control themes (for look and behavior)
  • Other resources external to the app
  • System (Windows 8.1) resources

The University of North Texas, ITDS Dept., Dr. Vedder

app xaml
App.xaml

The University of North Texas, ITDS Dept., Dr. Vedder

go to definition your friend
“Go to Definition”: Your Friend

“Peek” (Alt+F12) Also Your Friend

The University of North Texas, ITDS Dept., Dr. Vedder

this definition is in generic xaml a read only file
This Definition is in Generic.xaml(a read-only file)

The University of North Texas, ITDS Dept., Dr. Vedder

build your own resource dictionary if it will used by multiple projects in same soln
Build Your Own Resource Dictionaryif it will used by multiple projects in same soln.
  • Create the Dictionary as a separate file
  • Set as a resource in App.xaml

The University of North Texas, ITDS Dept., Dr. Vedder

retrieve app scope resources key names must match exactly in spelling case
Retrieve App-Scope Resourceskey names must match exactly in spelling & case

http://msdn.microsoft.com/en-us/library/windows/apps/hh968442.aspx

The University of North Texas, ITDS Dept., Dr. Vedder

static resource
Static Resource
  • Retrieved only once and available for the life of the app (value does not change)
  • Should be defined in XAML before use

The University of North Texas, ITDS Dept., Dr. Vedder

static resource syntax
Static Resource Syntax

(Most Common Usage)

The University of North Texas, ITDS Dept., Dr. Vedder

dynamic resource
Dynamic Resource
  • Retrieved each time requested (so the value could change during runtime)
  • Increases app overhead, so reduces app performance
  • Use StaticResource unless needed

The University of North Texas, ITDS Dept., Dr. Vedder

dynamic resource syntax
Dynamic Resource Syntax

The University of North Texas, ITDS Dept., Dr. Vedder

static v dynamic example a lot of code missing here
Static v. Dynamic Examplea lot of code missing here

<Page.Resources>

    <SolidColorBrush Color="LightBlue" x:Key="buttonBackground" />

</Page.Resources>

<StackPanel Name="stkPanel">

    <Button Name="Button1" Content="Button1"

            Background="{StaticResourcebuttonBackground}"/>

    <Button Name="Button2" Content="Button2"

            Background="{DynamicResourcebuttonBackground}"/>

    <Button Name="Button3" Content="Button3"

            Background="{StaticResourcebuttonBackground}"/>

</StackPanel>

----- Code behind----

void StaticAndDynamicResources_Loaded(object sender, RoutedEventArgs e)

{

stkPanel.Resources["buttonBackground"] = Brushes.Yellow;

}

The University of North Texas, ITDS Dept., Dr. Vedder

binding data binding
Binding (Data Binding)
  • Connecting a source property’s value with a target property’s value; the connection stays open during app’s life
  • Use when hard-coding values to properties is not a good idea (ex. runtime settings (ex., user moves slider), animations)
  • Is the Binding class in XAML & C#
  • Posts changes automatically eitherway
  • Supports complex data values

The University of North Texas, ITDS Dept., Dr. Vedder

common binding scenarios include
Common Binding Scenariosinclude
  • Binding a ListBox to a set of headlines
  • Binding an Image to a photo of the current user
  • Is OK to bind one source property to many target properties

The University of North Texas, ITDS Dept., Dr. Vedder

the binding target property must be a dependency property
The Binding Target Property Must Be A Dependency Property
  • A DP is a ‘super property’
  • A DP can have multiple providers for its value
  • A DP adds value to a static property
    • Self-contained validation
    • Change notification
    • Inheritance of property values
    • Support for multiple providers

The University of North Texas, ITDS Dept., Dr. Vedder

data binding model example
Data-Binding Model & Example

Binding sources include:

  • UI elements
  • Any object in a list
  • ADO.NET DataTables, .JSON file, etc.
  • Web services

The University of North Texas, ITDS Dept., Dr. Vedder

multiple providers power ranking not all possibilities shown here
“Multiple Providers” Power Rankingnot all possibilities shown here
  • Coertion (RT data feed altersprop. value)
  • Active animations
  • Local value (a binding or resource)
  • Template properties (TemplateBinding)
  • Implicit style (i.e., not named)

(Source must be on the same page or in the app)

The University of North Texas, ITDS Dept., Dr. Vedder

multiple providers ranking 2 not all possibilities shown here
“Multiple Providers” Ranking, 2not all possibilities shown here
    • Style triggers Triggerconditionally applies a value to a Style prop.
  • Template triggers
  • Style setters Setter applies a value to a Style property
  • Default (theme) style
  • Property value inheritance

The University of North Texas, ITDS Dept., Dr. Vedder

three different values for background
Three Different Values for Background
  • Local value=Red, so that’s the color
  • If just <Button> (w/o Background prop.)
    • Triggers take precedence over Setters, so
    • Blue if mouse over it, green otherwise

The University of North Texas, ITDS Dept., Dr. Vedder

so how to id a dependency property
So, How To ID a Dependency Property?
  • A DP name must end with ‘Property’
  • Intellisense will show DPs
  • Search property name in MSDN library; see if there is a ‘Dependency Property Information’ section

The University of North Texas, ITDS Dept., Dr. Vedder

how do i write a dp
How Do I Write a DP?
  • For newbies, the best course is to write the complete name, so that you understand better what you are doing, ex., TextBox.TextProperty
  • BUT… frequently coders use a ‘semantic shortcut’ and just write the first part of the DP and let the compiler figure it out, ex., TextBox.Text
  • (They get away with this because an ordinary, “CLR” prop is ‘backed by’ the DP)

The University of North Texas, ITDS Dept., Dr. Vedder

the binding object s mode prop controls the interaction behavior
The Binding Object’s Mode Prop. Controls the Interaction Behavior
  • OneWay
  • OneTime(to the target)
  • TwoWay(good for input controls)
  • OneWayToSource

The University of North Texas, ITDS Dept., Dr. Vedder

target update can be automatic but updating the source
Target Update Can be Automatic, But Updating the Source?

UpdateSourceTrigger values say when

  • PropertyChanged – ASAP, ex., online chat
  • LostFocus – when user moves away from target object, ex., data validation

The University of North Texas, ITDS Dept., Dr. Vedder

simple binding example in xaml
Simple Binding Example in XAML
  • Source object = MyData
  • Source property = ColorName
  • Target object = Button
  • Target DP = Background(.Property)

(Button inherits DataContext value)

The University of North Texas, ITDS Dept., Dr. Vedder

simple 2 way binding example
Simple 2-Way Binding Example
  • DP TextBox.Text defaults to 2-way, so no Mode property setting needed
  • Note use of ElementNameproperty, which allows binding to an element

The University of North Texas, ITDS Dept., Dr. Vedder

datacontext property
DataContext Property
  • Useful when you want many elementsinside a container to bind to the same source
  • Set the DataContext property in the parent container, then use inheritance

The University of North Texas, ITDS Dept., Dr. Vedder

sample datacontext usage
Sample DataContext Usage
  • Length refers to string fed to TextBlock.Text
  • {Binding} with no “Path=” means the entire source object (in this case, is just a string)

The University of North Texas, ITDS Dept., Dr. Vedder

itds logo mood slide
ITDS Logo / Mood Slide

The University of North Texas, ITDS Dept., Dr. Vedder