Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 227
  • Last Modified:

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

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.

  • 3
  • 3
2 Solutions
Fernando SotoCommented:
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.
Fernando SotoCommented:
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
BruceAuthor Commented:
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...
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Fernando SotoCommented:
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?
BruceAuthor Commented:
This has to do with the NavBarItem...
BruceAuthor Commented:
Because it wasn't really solved and I want the readers that find this to know.  

I gave the points to the only respondent

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now