Silverlight Pivot View Control – Part 1


 

Download Sample

 

Just before one month from now, I worked with a new company; I really loved my new Job. New experience taken from Michael Ruddick; He is a Chief architect in T-Force.

I will not forget to talk about Tareq Amin “The Vise president in T-Force”. He is a big fan of the new Metro Apps style; Yeah Metro is amazing.

Tareq is listening to me a lot, sharing Ideas, respecting people.
Also he is studying to make Google’s 80/20 Innovation Model part of our work; or maybe to do like Innvoation Center in Amman Office; That’s really coool!

Ok, Lets talk about some geeky stuff here. Watch the video to see the output; And If you like it; Continue reading and download the sample from link below. Smile

 

Download Sample

 

 

I’ve just created a simple control, I called it Pivot View Control.

Simply this control contains

PivotViewControl:
this control divided into three parts:
Title: Just a title for the Pivot Control (you can expose this property as a Dependency Property).
Header: Contains Items Control for Tabs (or Pivot Headers).
Content: Each header related with a UIElement which loaded in the Content Presenter.

<Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto" MinHeight="30"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <TextBlock TextWrapping="Wrap"
Text="Title, select one of items below"
VerticalAlignment="Center"
FontFamily="Segoe UI Semibold"
FontSize="21.333" Margin="7,0,0,0"/>
        <ListBox x:Name="PivotItemsHeaderList"
SelectedItem="{Binding SelectedItem, ElementName=PivotViewCtrl, 
Mode=TwoWay}"
                 Margin="0" Grid.Row="1"
Background="#00000000" BorderBrush="{x:Null}"
                 ItemsSource="{Binding Items, ElementName=PivotViewCtrl}"
                 ItemsPanel="{StaticResource ItemsPanelTemplate}"
                 ScrollViewer.VerticalScrollBarVisibility="Disabled"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
          ItemContainerStyle="{StaticResource ListBoxItemContainerStyle}"
                 FontFamily="Segoe WP SemiLight" FontSize="24"
                 ItemTemplate="{StaticResource DataTemplateListItem}"/>
      <ContentPresenter x:Name="ContentPresenter" Margin="0" Grid.Row="2">
          <ContentPresenter.Projection>
              <PlaneProjection CenterOfRotationX="0"/>
          </ContentPresenter.Projection>
      </ContentPresenter>
    </Grid>

The animation createed using Visual State Manager, In the next version I’m going to add many animation options. For now this animation is good Smile.

Simply you can change the animation using Expression Blend, Go to states tab in blend and change the animation.

I have two states in my control;

GoAway: will hide current displayed content. And this animation completed I will change the content of it.

ComeIn: When GoAway animation completed and content changed.  Start the animation to bring the new content.

Anim

This is the animation completed Event:

void StoryBoardGoAway_Completed(object sender, EventArgs e)
{
   string headerValue = this.PivotItemsHeaderList.SelectedItem.ToString();
   var pivotItem = this.ItemsSource
        .SingleOrDefault(p => p.Header == headerValue);
   this.ContentPresenter.Content = (UIElement)pivotItem.Content;
   VisualStateManager.GoToState(this, "ComeIn", true);
}

PivotItemControl.cs

This control is a dependency control; Its something like Tab Item.

public class PivotItemControl : DependencyObject
    {
        public DependencyProperty HeaderProperty =
            DependencyProperty.Register("Header", typeof(String),
            typeof(PivotItemControl), null);
         public String Header
        {
            get
            {
                return (String)GetValue(HeaderProperty);
            }
            set
            {
                SetValue(HeaderProperty, value);
            }
        }
        public DependencyProperty ContentProperty =
            DependencyProperty.Register("Content", typeof(UIElement),
            typeof(PivotItemControl), null);
         public UIElement Content
        {
            get
            {
                return (UIElement)GetValue(ContentProperty);
            }
            set
            {
                SetValue(ContentProperty, value);
            }
        }
    }

How to use it?

public MainPage()
        {
            InitializeComponent();
            this.Loaded += MainPage_Loaded;
        }
         void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            BindPivotItems();
            this.Loaded -= MainPage_Loaded;
        }
       private void BindPivotItems()
        {
          List<PivotItemControl> list = new List<PivotItemControl>();
          String[] headers = new string[] {"details","documents","notes"};
             foreach (string item in headers)
            {
                 list.Add(new PivotItemControl()
                        {
                            Header=item,
                            Content=new DummyContentControl() { Tag=item }
                        });
            }
           this.PivotViewControl.ItemsSource = list;
        }

Some enhancements could occurred; like using one Usercontrol as a Content; And Change the DataContent when GoAway Animation Completed. But I think you need to Expose an Event, Yeah that gonna be great.

My Experience with Mobile Ads


Salam Dears,

In the last months I was very busy; learnning Objective-C (iOS development). And the fruit comes with a simple application called Quraan Telawat.

You can find the link above in this page.  Anyway, one of the most interesting experience that i’ve got is the Ads.

Dude: what do you mean by Ads?
Me: Its an Advertising space that you reserve it in your application to browse Advertisements.

Dude: Are they advertising on your app? How did they know you?
Me: Actually, they do not know me. There are many known Ads providers in the world like google which have AdSense SDK, and AdFalcon for Noqush company.

Dude: ok, I see. Is it only for phones?
Me: nop, you can use it in your website, iOS apps, Android, and some of them are supporting WP7 also.

                _ _
Dude
: {$.$} … And what about the money?
Me: since 5th of November I’ve got around $43 … yeah not that much; but at the end its extra money comes from one app. In addition to the new experience.
I want to share with you this site which created by one of google’s team its called Guide to the App Galaxy

Dude: Interesting, Nice UI!!
Me: Yeah, It will answer all of your questions about monetizing your apps and some guidelines.

One more comment dude, I have till now 4,000 users. but actually not all of them are an active users now. so I found this wonderful tool that you can add it to your app and it will send to you the number of active users at this moment.

Dude: really!!
Its called Google Analytics. And you can download the SDK from here. This SDK is mentioned in that Guide Galaxy portal.

Dude: You said that there are many Ads providers. What should I use?
Me: Actually I found Admob really great.

Dude: Why?

Me: Let me share with you something

This image contains a stats for each day. Number of Impressions, Requests, Fill Rate, ..a

Dude: wait wait. Requests & Impressions … what is the deference?

Me: When a user open the app. … It will request an Ad.  but it could comes with Ad … And if it comes with Ad … Thats an Impression.

Dude: Is there a way to make sure that all requests comes Impressions?
Me: Yeah, AdMob already have this … they are also displaying Ads from AdSense .. And you can also handle this by code. So if there is no impassion display Ad from another provider. But its not the optimal way to solve this problem.

You can use “The mediator approach”… the mediator SDK will do the whole work and jumping between providers till it comes with an impression.

Its called AdWhirl … I did not use it till now but it seems great.

Wishing you a googd luck dude, Good night.
Dude: Good night.

Step by Step – Filtering List using Reactive Extensions (Rx Framework)


  1. Download Rx Framework from here.
  2. Install it.
  3. Create New Windows Forms project (you can choose WPF, Silverlight, WP7). I used WinForms in my example.
  4. Add TextBox and ListBox to it as you see below.

Screen shot 2011-07-14 at 1.50.46 AM

  5.   Add System.Reactive reference to your project (see image below).

Screen shot 2011-07-14 at 1.53.05 AM

6.  Create any dummy data (you can use any repository you want) and just to make things fast Smile

Screen shot 2011-07-14 at 1.51.58 AM

7. Add this chunk of code.

Screen shot 2011-07-14 at 1.52.17 AM

When TextChanged raised the subscribed code will be executed Asynchronously.

That’s it. As simple as that.

Good night. Smile

Dev-igner On Blend4


I just finished my preparation for the session.

Why Dev-igner? For me, I see Blend as a tool that helps developers & Designers (Maybe the proper name is frontend Developers) … anyway, I’m sure that WPF, Silverlight is rarely used in Jordan; Because of:

1. Learning Curve; and as always I hear & I say: There is no time; so the small biz companies prefer to stick with Win Forms.

2. More Effort will be consumed to add WOOW effect to the application.

3. And Who Should Learn Blend? Developers? But they Love Visual Studio and they prefer to stay with it. Designers?! Same thing, they prefer illustrator & Photoshop.

I agree with you both guys? But I’m sure that you did consume any moment to know that Blend is a great tool.

It’s easier to bind targets with source, Styling & templating, XAMLing things, also you can Import your .AI, .PSD, and FXG files, and more.

If we say that Dev. should work on Blend; then he will do a catastrophe. (Thanks to their ugly taste).

And the Designer cannot do the whole Blendy things a lone also.

Finally, I face such situation and I played the 2-Face character in batman (the ugly side is the dev part); XAMLing things with VS 2008 is a really Shit. Things are better with VS 2010 but not so much.
I forced to learn it and now I do not regret.

BLEND is the Best… I can imagine if Microsoft create such a tool for HTML5… I cannot wait for that moment.

Hoping you to enjoy my session:

The Event will be at 15 June 2011 in Sumayah University.

JorDev will keeps you updated insha Allah.

 

Silverlight training for Designers


Today I finished a special training which given by a Shane Morris.

About Shane Morris

Shane Morris is one of Australia’s most respected user experience professionals. Through consulting, mentoring and training he has helped organizations create compelling digital experiences since 1991. In that time he has worked on desktop applications, internet applications, mobile user interfaces, physical devices and web sites. Shane has taught user experience topics around the world and is also a key contributor to “101 Things I Learned in Interaction Design School” at ixd101.com.

Shane has worked with companies like Microsoft, Lonely Planet, M&C Saatchi, Cochlear, Amnesia Razorfish and Sensis – helping creative and technical professionals collaborate to create services that empower, inspire and reward. His passion is transforming the complex and constrained into the simple and powerful. Not just because it’s valuable endeavour, but because it’s hard – and therefore immensely rewarding.

Shane’s previous experience includes:

  • One of Microsoft’s first User Experience Evangelists world-wide.
  • Director of Echo Interaction Design for 6 years.
  • General Manager and Principal Consultant at The Hiser Group.

 

Its really awesome training. thank you AGENDA group and thank you Microsoft.

And special thanks for eSense to pay for that :).

RadControls for Windows Phone 7


Looool, I’ve got this mail from Telerik and I have a free WP7 RadControls license. I’m so happy for that.

I want to thank my TweetDeck Application for that Smile; It helps me to be one of the early people whom download the controls.

Hello Mohammad,

Thank you for downloading the CTP version of RadControls for Windows Phone.

I’m happy to let you know that as an early adopter you will receive a free license for RadControls for Windows Phone, when the product is officially released with Q1 2011. On the day of the release you will have the official version of RadControls for Windows Phone in the Download and Manage Your Products -> RadControls for Windows Phone 7 -> Product Downloads section of your Telerik account.

Our product team will greatly appreciate you feedback, do not hesitate to share it with them.

And if you are working on a Windows Phone application built with our controls, share it with us and we will help you promote it. For showcase submissions contact me directly.

Once again, thank you for your interest in our product and good luck with your development.

Ina Tontcheva

RadControls for Windows Phone Brand Manager

Telerik

http://www.telerik.com