Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8758059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:27:05+00:00 2026-06-13T14:27:05+00:00

<Grid Grid.IsSharedSizeScope=True Name=treeGrid Grid.Column=1 Grid.Row=1 Grid.ColumnSpan=3> <Grid.RowDefinitions> <RowDefinition Height=Auto /> <RowDefinition /> </Grid.RowDefinitions> <Grid.Resources>

  • 0
<Grid Grid.IsSharedSizeScope="True" Name="treeGrid" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="3">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition />
    </Grid.RowDefinitions>
    <Grid.Resources>
        <local:LevelConverter x:Key="levelConverter" />
        <HierarchicalDataTemplate ItemsSource="{Binding Items}"
                              DataType="{x:Type local:DirectoryRecord}">
            <Grid ShowGridLines="False">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition SharedSizeGroup="rowHeaderColumn"/>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition SharedSizeGroup="column1"/>
                    <ColumnDefinition SharedSizeGroup="column2"/>
                    <ColumnDefinition SharedSizeGroup="column3"/>
                    <ColumnDefinition SharedSizeGroup="column4"/>
                    <ColumnDefinition SharedSizeGroup="column5"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0"
                       Text="{Binding Name}"></TextBlock>
                <Rectangle Grid.Column="1">
                    <Rectangle.Width>
                        <MultiBinding Converter="{StaticResource levelConverter}">
                            <Binding Path="Level"></Binding>
                            <Binding ElementName="treeViewItemToMeasure" Path="ActualWidth"></Binding>
                        </MultiBinding>
                    </Rectangle.Width>
                </Rectangle>
                <TextBlock Grid.Column="2"
                       Text="{Binding LastAccessed}"></TextBlock>
                <TextBlock Grid.Column="3"
                       Text="{Binding Files.Count}"></TextBlock>
                <TextBlock Grid.Column="4" 
                       Text="{Binding Inherited}"></TextBlock>
                <Grid.Style>
                    <Style TargetType="{x:Type TextBlock}">
                        <Setter Property="Background" Value="Aquamarine" />
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Path=Inherited}" Value="True">
                                <Setter Property="Background" Value="Black" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Grid.Style>
            </Grid>
        </HierarchicalDataTemplate>
    </Grid.Resources>
    <TreeView>
        <!-- My binding goes here -->
    </TreeView>
</Grid>

I’m trying to change the background of the TextBlock contained within my custom Grid(TreeGrid), however this code fails with XamlParseException

‘TextBlock’ TargetTypes does not match type of element ‘Grid’.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:27:06+00:00Added an answer on June 13, 2026 at 2:27 pm

    Instead of defining a style inside a Grid.Style section, you have to declare it as the Grid.Resource Style, with the TargetType specified, i.e.

    <Grid.Resources>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="Background" Value="Aquamarine" />
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=Inherited}" Value="True">
                    <Setter Property="Background" Value="Black" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Grid.Resources>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this very simple XAML window: <Grid> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <ContentControl Content={Binding
I have the following scenario in XAML: <Grid Grid.IsSharedSizeScope=True> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition />
I have a dojox.grid.DataGrid where I want to select a row programmatically. I'm using
I have a Telerik Grid which has a footer that needs to display column
Grid example with the trigger: <Grid x:Name=LayoutRoot DataContext={Binding ProjectGrid, Source={StaticResource Locator}}> <i:Interaction.Triggers> <i:EventTrigger EventName=Loaded>
Extjs grid Model has, { name: ORDERDATE, type: 'date', dateFormat: 'MS' } and I
I have a ListBox that contains a Grid. The Grid has a Label Column,
When I create a grid using both a SharedSizeGroup on columns and a column
I have a grid with 5 cols and 10 rows and in each column
I have a 3 column grid in a window with a GridSplitter on the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.