... all I'm offering is the truth. Nothing more. RSS 2.0
# Friday, May 15, 2009

I have been working on a WPF side project at work and wanted to make a quick note about creating and consuming WPF user controls. My example was much more replete with details but i was more interested in making a note of the code that ties your XAML directly to the code.

So you create control in the normal VS type of way and this will give you a really basic XAML page (I have removed some of the distracting details). I have dropped a label on the screen as this will serve as the control that I will programmatically manipulate.

<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="MyNameSpage.Dog"
    x:Name="UserControl"
    Width="Auto" Height="Auto" mc:Ignorable="d">

    <Canvas x:Name="ParentCanvas" PreviewMouseMove="ButtonMove" OpacityMask="#FF000000">
        <Label Grid.Column="0" Grid.Row="2" x:Name="NameLabel" HorizontalAlignment="Center" >ENGINEER</Label>
    </Canvas>
</UserControl>


and here is the associated partial class that documents our implementation code.

public partial class Dog
{

        public static readonly DependencyProperty DogsNameProperty = 
            DependencyProperty.Register("Dogs Name", typeof(string), typeof(Dog), 
             new FrameworkPropertyMetadata(DogsNamePropertyChange));


        public string DogsName
        {
            get
            {
                return (string)base.GetValue(DogsNameProperty);
            }
            set
            {
                base.SetValue(DogsNameProperty, value);
            }
        }
        

        private static void DogsNamePropertyChange(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            (source as Dog).NameLabel.Content = (source as Dog).DogsName;
        }
}
  • Basically we register the property using the DependencyProperty.Register method
  • We make it publicly accessible via the DogsName property
  • We monitor changes DogsNamePropertyChange

Simple!

Technorati Tags: ,
Friday, May 15, 2009 3:39:24 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] - Trackback
WPF
# Thursday, May 14, 2009

image



Several months ago I had opted to receive SMS Live alerts for a variety of services that included headlines, scores, stocks, and new emails. Unfortunately I was getting mail alerts at all hours of the night and this was frustrating me, and more importantly my better half.

So a quick look at the Mobile options on Live showed that I can select blackout times where I do not want to receive SMS alerts. Additionally you have the option to send alerts after the blackout period or simply discard them.

If your cell phone service has a cap on text messaging, you can reflect that in the number of alerts you receive from Live in a given month. I am really jazzed about it … here is to a good nights sleep.


 

 

 

 

 


 

Technorati Tags: ,

Thursday, May 14, 2009 9:44:32 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] - Trackback
Windows Live
# Wednesday, May 06, 2009

How many times have we had to solve the shared printer scenario at home, or simple file sharing within a home network (I am assuming most of us have not setup a full blown windows network).

Windows 7 finally resolves this issue with a simple shared key…

Get Microsoft Silverlight

 

Technorati Tags:
Wednesday, May 06, 2009 1:30:23 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] - Trackback
Windows
# Tuesday, April 28, 2009

After arriving at Las Vegas airport I remember being really impressed by the ample places I could charge my laptop and even my USB devices for free. In recent memory it took quite a lot of skill and patient preparation to be in the right seat at the right time to get the only outlet near your gate. Now it seems everyone has a laptop notebook and the airports have responded accordingly.

Imagine my surprise as I was walking though the terminal to see the Charge Carte beckoning to me…

IMAGE_131

A singular device with almost every type of charging cable available to cater for the person who rushed out and forgot their charger. You now have the option to get a quick charge for the most popular devices (includes Motorola, Nokia, Samsung, LG, Kyocera, Blackberry, Palm, Siemens, Sony-Ericcson, Nextel, iPod and iPhone).

Sounds like a good idea … until you see the price Charge Carte is charging ;)

IMAGE_132

 

 

 

 

 

 

 

Technorati Tags:
Tuesday, April 28, 2009 9:53:17 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] - Trackback
Electronics | Other things

Live Mesh is now in general availability for the Windows Mobile devices. I am really glad about this, I had blogged about a long winding method to circumvent the limited roll out some months ago. Now the only problem is whether to use Live Mesh or My Phone. Personally I am going to settle on which ever service integrates with Live SkyDrive first.

UPDATE: If you are getting this error: “Time mismatch with server” then your version needs to be updated.

Technorati Tags:
Tuesday, April 28, 2009 9:12:20 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] - Trackback
Windows Live
# Monday, April 27, 2009

I spent an eternity trying to figure out how to wrap text using WPF … here is the code snippet for future reference":

<Label Grid.Column="0" Grid.Row="1" x:Name="MyTitle" HorizontalAlignment="Center" FontFamily="Segoe UI" FontSize="12" MaxWidth="175">
    <TextBlock x:Name="MyText"  TextWrapping="Wrap">TITLE</TextBlock>
</Label>
Technorati Tags: ,,
Monday, April 27, 2009 2:13:56 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] - Trackback
WPF
Blogroll
Statistics
Total Posts: 334
This Year: 22
This Month: 0
This Week: 0
Comments: 32
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Mark Downie
Sign In
All Content © 2010, Mark Downie
DasBlog theme 'Business' created by Christoph De Baene (delarou)