In XAML, How does a Grid inherit properties base on its "Name"?

Posted on 2014-08-07
Last Modified: 2014-08-30
I have picked up responsibility for an app I did not originate and am still relatively new to XAML.

I have a <Grid> at the base of a usercontrol that seems to be inheriting properties when it has the "Name" attribute set.  I have done a "Find" on the "Entire Solution" for the name but don't see where this code is being setup.  I have looked in Resources files specifically but nothing there either, that I can see.

Question by:Bruce
    LVL 62

    Expert Comment

    by:Fernando Soto
    Hi Bruce;

    You state the following, "I have a <Grid> at the base of a usercontrol that seems to be inheriting properties when it has the "Name" attribute set. ", from Microsoft documentation:

    Property Value Inheritance
    Property value inheritance enables child elements in a tree of elements to obtain the value of a particular property from parent elements

    So it is not based on it having a Name attribute.  If you can post the user control and give a detail description of what you are trying to find I will see If I can help. Also please read the post Property Value Inheritance.
    LVL 62

    Expert Comment

    by:Fernando Soto
    Is this maybe what you mean?

    You can also change the look of a control by using Named resource keys in the resource section of the XAML or resource dictionary.

    XAML Resources
    LVL 1

    Author Comment

    On your second question, yes, we have Resource files that contain Styles and TargetTypes but none seem to match the control type I am using.

    Here's the code...
    <UserControl x:Class="CST.CustomerService.Forms.Views.Compliance.ZeroUsageFormView"
                 d:DesignHeight="300" d:DesignWidth="1000">
                <DataTemplate DataType="{x:Type sdmfvm:SharedGeneralCustomerInfoControlViewModel}">
                    <sdmfv:SharedGeneralCustomerInfoControlView />
                <DataTemplate DataType="{x:Type fvm:CustomerServiceTransactionsFormViewModel}">
                    <fv:CustomerServiceTransactionsFormView />
                <DataTemplate DataType="{x:Type fvm:CustomerServiceDeviceFormViewModel}">
                    <fv:CustomerServiceDeviceFormView />
        <Grid Name="MainGrid" HorizontalAlignment="Stretch" Visibility="Visible" Margin="0,4,0,-4" Background="White">

    Open in new window

    When I remove the "Name" Attribute from the <Grid...> declaration then I am able to set the background color...and have it stick.  

    I am trying to override at behavior I think is in the DevExpress NavBarItem control that Highlights the control on mouseover.  I have not been able to disable this behavoir or override with the Styles or triggers so I've opted to just set the background to white for now and solution it down the road.

    Hope that code helps...  Thanks for responding...
    LVL 62

    Assisted Solution

    by:Fernando Soto
    Well the only way the Background color is going to change is through code, you say you did a search in all the files in the project, you searched for the name MainGrid, correct?
    LVL 1

    Accepted Solution

    This has to do with the NavBarItem...
    LVL 1

    Author Closing Comment

    Because it wasn't really solved and I want the readers that find this to know.  

    I gave the points to the only respondent

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now