Social Icons

twitter google plus linkedin rss feed

Pages

22.4.11

Stratex Systems is On The Cloud

I have just received the link to join the Office 365 beta program… Sadly (again) I don’t have the time to test it properly today, but I will on Tuesday hopefully.

I’ll keep you posted.

 

image

 

A lot of licenses to assign, a lot of software to try…

No comments:

Post a Comment

21.4.11

Debugging Windows Phone 7 applications

Finally I managed to upload and debug my application in my phone, but it wasn’t that easy…
First of all I found the instructions in this page http://msdn.microsoft.com/en-us/library/ff941089(v=vs.92).aspx#BKMK_Register
 
There, it says that you have to register in the App Hub before you are able to do anything with your phone (and it costs USD100…) the textual words are:

“You should register for membership as a Windows Phone developer before you begin creating applications because some development tasks, such as installing your application on a physical phone for testing, require App Hub membership”

Well this means you have to pay $100 only to be able to test the application… Pay before, decide later. I can’t say I like the philosophy.
 
Well, in the end my boss registered to the APP HUB with his personal Live ID. Huge mistake. We knew we could add up to three development phones, but no one told us that all of them should be linked to the same Live ID…  We thought you would be able to invite your developers to the App Hub or something like that, but no. And there’s no turning back, you can’t link your subscription to a different Live ID once you are registered… Not happy with this one either. Want to know how we solve it? With a great dose of trustfulness on his side.
 
Once you have your Live ID registered to the App Hub everything is easier…
 
I got to unlock and register the phone using  the Developer Phone Registration tool http://msdn.microsoft.com/en-us/library/ff769508(VS.92).aspx… Cool… Now what?
Well, now you have everything set up.
 
If you want to run your application in your phone anytime you want you have to deploy it with the “Application Deployment” tool as described in http://msdn.microsoft.com/en-us/library/gg588378(v=vs.92).aspx
 
Or if you prefer, you can hit F5 on your Visual Studio get the application running on my phone, and finally… Debug!

No comments:

Post a Comment

Creating a Expander Control for Silverlight for Windows Phone

I was migrating a solution to WP7 when I realized that there was not expander control available… I downloaded then the Silverlight  for Windows Phone Toolkit but realized that there wasn’t an expander there either.
 
I really couldn’t conceive a new version of the tool without expanders so I have created a rudimentary Expander for WP7. It's composed by a Grid, a StackPanel and a TextBlock.

It is very limited and of course it's not supposed to be a substitute of the good old Expander (it's focused to the specific problem I was trying to solve), but maybe it can help someone else out there.

The XAP code of the control is:
<Grid x:Name="LayoutRoot">
  <Border VerticalAlignment="Top" BorderBrush="#FF929EB0" BorderThickness="1" CornerRadius="2" Background="#FFE9E9E9" Margin="5,2">
            <Grid d:LayoutOverrides="Width">
    <Grid.RowDefinitions>
     <RowDefinition Height="Auto" MinHeight="20"/>
     <RowDefinition Height="Auto" MinHeight="5"/>
    </Grid.RowDefinitions>
    <TextBlock x:Name="Header" TextWrapping="Wrap" d:LayoutOverrides="Width" Foreground="#FF656565" Margin="15,2,0,0" VerticalAlignment="Top"/>
    <StackPanel x:Name="ChildrenPanel" VerticalAlignment="Top" d:LayoutOverrides="Width" Margin="0,2,0,0" Grid.Row="1"/>
   </Grid>
  </Border>
 </Grid>
The trick is adding a TextBlock in the header of the "expander" and subscribe to the MouseLeftButtonUp event of the TextBlock to control the folding and unfolding. I have also added a Folded property so I can externally set up the status of the expander.

If the expander is folded I add the items to the stack panel, if the expander is unfolded I remove the items. Sounds really simple, but I couldn't make it work. The StackPanel will remain the same size it was when it has all the items in it, but empty… without any Children… too ugly.

After a while trying to fake the behaviour changing the Height of the StakPanel I found the solution.

I was trying to delete all the items in the StackPanel at once with Children.Clear and that was driving it nuts. The solution was to remove the items inside the children one by one.

The code for the Expander class is here.
public partial class Expander : UserControl
 {
        bool _Folded;
        public bool Folded
        {
            get { return _Folded; }
            set
            {
                _Folded = !value;
                ExpanderSwitch();
            }
        }
        List ChildrenList;


  public Expander()
  {
   // Required to initialize variables
   InitializeComponent();

            ChildrenList = new List();

            Header.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(UserActivity_MouseLeftButtonUp);
  }

        void UserActivity_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            ExpanderSwitch();
        }

        private void ExpanderSwitch()
        {
            if (Folded)
            {
                foreach (var child in ChildrenList)
                    ChildrenPanel.Children.Add(child);
            }
            else
            {
                if (ChildrenList.Count == 0)
                    foreach (var item in ChildrenPanel.Children)
                        ChildrenList.Add(item);

                while (ChildrenPanel.Children.Count > 0)
                    ChildrenPanel.Children.RemoveAt(0);
            }

            _Folded = !_Folded;
        }
 }
And to use it you just have to add the control:
<Grid x:Name="LayoutRoot">
        <this:Expander x:Name="UserNews" />
    </Grid>
In code behind you can do something like this:
UserNews.Header.Text = GetHeader(News[0]);

            foreach (FrameworkNews news in News)
                UserNews.ChildrenPanel.Children.Add(new NewsDetail(news.Link, GetDetail(news), news.Where));

            UserNews.Folded = true;
If you have time you can add images and animations to the expander as well as a better "Folding Control"… Sadly I can't spend more time working on it, even though I'd love to :(

No comments:

Post a Comment