This is a mirror of official site: http://jasper-net.blogspot.com/

DataBinding to Custom Properties

| Thursday, September 8, 2011
In a recent three part mini-series I showed how to create a Xaml program CalcDisplay from scratch.  In the third part of the series I showed how the values are computed for display, but I glossed over how the display value is bound to the display control itself.  Let’s focus on that for a moment in what I guess is now part 4 of the three part series.

As noted in part 3, we begin by looking at the DisplayNumber property.  When all is said and done, this property will have the value that should be displayed in the output window.  Here’s the Xaml for the output window:

<Border
    Margin="4,14,0,16"
    Grid.Row="1"
    Width="476"
    Height="74"
    Background="#FF9B9B9B"
    d:IsHidden="True">
    <TextBlock
        TextWrapping="Wrap"
        Text="TextBlock" />
</Border>

Notice that the TextBlock is wrapped in a Border. TextBlocks cannot set the background color, but Borders can.  In our case, we’re going to want to adjust some of the properties of the TextBlock. The easiest way to do this is to open the project in Blend and click on the TextBlock to update its properties.

Set the font-size to 30 point, set the font to Segoe WP Semibold and click Bold as well, and use the paragraph tab to align to the right, and VerticalAlignment to center.  Finally, click on the Foreground color and change it from white (255,255,255) to black (0,0,0).


Read more: Jesse Liberty
QR: https://chart.googleapis.com/chart?chs=80x80&cht=qr&choe=UTF-8&chl=http://jesseliberty.com/2011/09/06/databinding-to-custom-properties/

Posted via email from Jasper-net

0 comments: