简体   繁体   中英

Why does visual studio add “p:” to all my controls?

I've noticed that if I add a control by dragging it from the toolbox, the letter p, followed by a colon, is appended to the beginning of the control name, and also some of it's properties. The "XAML Styler" extension also seems to do the same when you format.

I've noticed that everything (at least seems to) have the same exact behavior if you take off all the p's.

Is there any benefit to having, say

<p:Rectangle
    x:Name="leftPanel"
    Grid.Row="1"
    Fill="#FF2F3136" />

rather than

<Rectangle
    x:Name="leftPanel"
    Grid.Row="1"
    Fill="#FF2F3136" />

It is just adding the reference to the namespace which would be defined at the top of the XAML document, like for example here:

<Page x:Class="WPFApplication1.MainPage"  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
    xmlns:custom="clr-namespace:SDKSample;assembly=SDKSampleLibrary">  
  ...  
  <custom:ExampleClass/>  
...  
</Page> 

You should probably find a reference to System.Windows.Shapes defined in the namespaces at the top of your document

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM