Wednesday 27 May 2015

Element Binding in Xaml

XAML element binding allows binding of different elements through properties which means providing value to particular element from another element's value.
Following code describes this process in which font size of text block is bound to value property of slider element.

1  >Open Visual Studio
2  >Start new project
3 >Select windows phone app And choose blank page
4 >Open MainPage.xaml from solution explorer 
Now copy and past following code.


<Grid>
        <Slider Minimum="40" Maximum="100" Name="slider1"></Slider>
       <TextBlock FontSize="{Binding Value, ElementName=slider1}" Text="simple text"></TextBlock>
    

</Grid>

The above code shows that the value of font size will be increased as the slider moves.


Flip View Controls using xaml (windows phone + store)

In old days we use pivot controls and panorama for representation of data in windows phone (silver light). But now a days these controls are replaced by Filp View controls. Here is short code snippet that shows how to use Hub controls in windows phone + store apps.

The code is quite easy to understand and self explanatory.


<FlipView>
<FlipViewItem>
<TextBlock FontSize=”400″ HorizontalAlignment=”Center” VerticalAlignment=”Center”>Apple</TextBlock>
</FlipViewItem>
<FlipViewItem>
<TextBlock FontSize=”400″ HorizontalAlignment=”Center”
VerticalAlignment=”Center”>Ball</TextBlock>
</FlipViewItem>
</FlipView>

Hub Control using xaml (windows phone + store)


In old days we use pivot controls and panorama for representation of data in windows phone (silver light). But now a days these controls are replaced by Hub controls. Here is short code snippet that shows how to use Hub controls in windows phone + store apps.

The code is quite easy to understand and self explanatory.


<Hub Header="Virtual University of Pakistan">
<HubSection Width="400" Header="Student"></HubSection>
<HubSection Header="Roll No"></HubSection>
<HubSection Header="Courses"></HubSection>
</Hub>