advertisement
Windows 10 Apps Development
get { return ageValue; }
set
{
if (value != ageValue)
{
ageValue = value;
}
}
}
}
}
When the above code is compiled and executed, you will see the following window. Click the Display button.
Let us change the Name and Age and click the Display button again.
You can see that in click button ‘Display’, the text of the textboxes are not used to show the data on TextBlock but the class variables are used.
I recommend you to execute the above code with both cases for better understanding.
Element Binding
It is also possible to bind, not to a standard data source, but rather to another element on the page. Let us create an application called ElementBinding in which a Slider and a
Rectangle are created and with the slider, the rectangle width and height are bound. Given below is the code in XAML.
36
Windows 10 Apps Development
<Page
x:Class="ElementBinding.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ElementBinding"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<Rectangle Height="100" Width="100" Fill="SteelBlue"
RenderTransformOrigin="0.5,0.5" Margin="50">
<Rectangle.RenderTransform>
<CompositeTransform ScaleX="{Binding Value,
ElementName=MySlider}"
ScaleY="{Binding Value,
ElementName=MySlider}"/>
</Rectangle.RenderTransform>
</Rectangle>
<Slider Minimum=".5" Maximum="2.0" StepFrequency=".1"
x:Name="MySlider" />
</StackPanel>
</Grid>
</Page>
When the above code is compiled and executed, you will see the following window.
37
Windows 10 Apps Development
With a slider, you can change the size of the rectangle as shown below.
38
advertisement
Related manuals
advertisement
Table of contents
- 5 Introduction
- 5 Universal Windows app
- 6 Characteristics of UWP apps
- 6 Development Choices
- 7 Windows 10 – UWP
- 7 Universal Windows Platform (UWP)
- 8 Devices Supported by Windows
- 8 Advantages of UWP
- 8 Setup for UWP Development
- 10 Windows 10 – First App
- 19 Windows 10 – Store
- 20 Monetization
- 20 Microsoft Advertising
- 27 Windows 10 – XAML Controls
- 27 XAML Emerging Story
- 28 Layout Controls
- 29 UI Controls
- 35 XAML – Data Binding
- 35 One-way Data Binding
- 37 Two-way Data Binding
- 40 Element Binding
- 43 XAML Performance
- 43 Progressive Rendering
- 47 Deferred Loading
- 51 Adaptive Design
- 51 New Built-in Features
- 52 Universal Building Blocks
- 54 Adaptive UI
- 54 VisualStateManager
- 56 RelativePanel
- 59 Adaptive Code
- 59 Writing Code
- 61 Win32 APIs in the UWP
- 70 File Management
- 70 File Locations
- 71 File Handling APIs
- 77 SQLite Database
- 77 What is SQLite?
- 77 Advantages of SQLite
- 89 App to App Communication
- 89 Getting Your App Ready
- 96 App Localization
- 96 Translating UI Resources
- 112 App Lifecycle
- 113 Process State Transition
- 120 Background Execution
- 120 Create and Register Background Task
- 127 APP Services
- 136 Web Platform
- 136 Advantages
- 143 Connected Experience
- 144 Roaming in Windows
- 151 Navigation
- 151 Page Models
- 151 Navigation Structure
- 158 Networking
- 158 Capabilities
- 159 Networking Technologies
- 162 HttpClient
- 164 Cloud Services
- 164 Microsoft Account
- 175 Live Tiles
- 175 Tile Anatomy
- 175 Updating Tiles
- 180 Sharing Contract
- 180 Sharing Content
- 181 Receiving Shared Content
- 188 Porting to Windows
- 188 Porting a Windows 8.x Project to a UWP Project