CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: How to use XAML to share some of the properties of multiple TextBlocks

  1. #1
    Join Date
    Jan 2018

    Question How to use XAML to share some of the properties of multiple TextBlocks

    Is there a standard way in XAML to collect similarly derived properties with the same values from several controls into one place? What is the best way to do it? The code below demonstrates the functionality I am thinking of with WPF TextBlocks, although it doesn't do what I want. It ignores the Canvas.Left and Canvas.Top property values and concatenates each successive fragment of text (starting at Left,Top=0,0). Canvas.Left,Top are what the designer used in <TextBlocks>—lines which I duplicated and reformatted into the below. I didn't see any x, y properties in class TextBlock itself. (Perhaps I simply should be using something other than Canvas.Left, Top for the TextBlocks' x,y?)

    DrawingWindow is defined as (C#): public class DrawingWindow : Canvas { }
    to which I intend to add additional drawing methods.
    <local:DrawingWindow x:Class="MyApp.WelcomeScreen"
        d:DesignHeight="500" d:DesignWidth="500"
        <TextBlock Foreground="Orange" HorizontalAlignment="Left" Height="25" VerticalAlignment="Top" Width="350" FontFamily="FreeSans" FontSize="14">
            <TextBlock Canvas.Left="100" Canvas.Top="100" Text="Now is the time\nfor all good men"/>
            <TextBlock Canvas.Left="120" Canvas.Top="150" Text="to come to"/>
            <TextBlock Canvas.Left="140" Canvas.Top="200" Text="the aid of their country."/>

  2. #2
    Join Date
    Jan 2018

    Re: How to use XAML to share some of the properties of multiple TextBlocks

    I have moved this question elsewhere. (At the moment it is here.)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)