Print Page | Close Window

Multiple Styles in Markup

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=10673
Printed Date: 04 May 2024 at 2:29pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Multiple Styles in Markup
Posted By: jpbro
Subject: Multiple Styles in Markup
Date Posted: 18 May 2008 at 11:50pm
Is there a way to add multiple styles to a markup tag?

For example, I have the following markup:


<Page>
    <Page.Resources>
        <Style x:Key="TotalRow">
            <Setter Property="Border.BorderBrush" Value='Black'/>
            <Setter Property="Border.BorderThickness" Value='0,1,0,0'/>
            <Setter Property="TextBlock.FontWeight" Value='Bold'/>
        </Style>
        <Style x:Key="Negative">
            <Setter Property="TextBlock.Foreground" Value='Red'/>
        </Style>
    </Page.Resources>

    <Grid Margin="30">
        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="50" MaxWidth="200"/>
            <ColumnDefinition MinWidth="50" MaxWidth="150" />
         <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

         <TextBlock Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" FontSize="14">Base Contract</TextBlock>
        <TextBlock Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" FontSize="14" HorizontalAlignment="Right">500.00</TextBlock>
         <TextBlock Grid.Column="0" Grid.Row="1" VerticalAlignment="Center" FontSize="14">Approved Changes</TextBlock>
        <TextBlock  Style="{StaticResource Negative}" Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" FontSize="14" HorizontalAlignment="Right">-600.00</TextBlock>
        <Border Style="{StaticResource TotalRow}" Grid.Column="0" Grid.Row="2">
            <TextBlock Grid.Column="0" Grid.Row="2" VerticalAlignment="Center" FontSize="14">Revised Contract</TextBlock>
        </Border>
        <Border Style="{StaticResource TotalRow}" Grid.Column="1" Grid.Row="2">
            <TextBlock Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" FontSize="14" HorizontalAlignment="Right">-100.00</TextBlock>
        </Border>
    </Grid>
</Page>


The -600.00 cell has the Negative style applied (works as expected), but I would like to be able to add the Negative style AND the TotalRow style to the bottom right cell (-100.00). I've tried a few variations like:

 Style="{StaticResource TotalRow, Negative}"
 Style="{StaticResource TotalRow, StaticResource Negative}"
  Style="{StaticResource TotalRow}, {StaticResource Negative}"
 Style="{StaticResource TotalRow}"  Style="{StaticResource Negative}"

With no success. Is this possible, or do I need to create a third style that encapsulates TotalRow and Negative?

Thanks.


-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6




Replies:
Posted By: Oleg
Date Posted: 19 May 2008 at 1:27am
Hi,
 
You can inherit Negative from TotalRow:
 
   <Style x:Key="Negative" BasedOn="{StaticResource TotalRow}">     
     <Setter Property="TextBlock.Foreground" Value='Red'/>    
   </Style>   
 


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net