Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I've customized disp page for external list item with SharePoint Designer (need to hive dome fields) and I've found xaml code in XmlDefinition property.

In our case we want to hide several field from disp item page but we have no idea how to do that task with OM as well as with SharePoint Designer.

Its a bit tricky cause I can't find any info and explanation about this (xaml in XmlDefinition and how it renders to html output). Does anybody know something about this technique?

<WebPartPages:XsltListFormWebPart runat="server" Description="" ListDisplayName="" FrameType="Default" PartOrder="2" HelpLink="" AllowRemove="True" IsVisible="True" ViewGuid="" AllowHide="True" UseSQLDataSourcePaging="True" ExportControlledProperties="False" DataSourceID="" Title="" ZoneID="Main" ViewFlag="0" FormType="4" AllowConnect="True" PageType="PAGE_DISPLAYFORM" FrameState="Normal" CatalogIconImageUrl="/_layouts/images/itebl.png" PageSize="-1" PartImageLarge="/_layouts/images/itebl.png" AsyncRefresh="False" Dir="Default" DetailLink="/tupolev/Lists/_2" ShowWithSampleData="False" ListId="975a8e0f-c140-4635-acf7-f927f2ccaa68" ListName="{975A8E0F-C140-4635-ACF7-F927F2CCAA68}" NoDefaultStyle="" PartImageSmall="" IsIncluded="True" SuppressWebPartChrome="False" AllowEdit="True" ControlMode="Display" ManualRefresh="False" AutoRefresh="False" AutoRefreshInterval="60" AllowMinimize="True" WebId="00000000-0000-0000-0000-000000000000" ViewContentTypeId="" InitialAsyncDataFetch="False" GhostedXslLink="formxml.xsl" MissingAssembly="Cannot import this Web Part." HelpMode="Modeless" ListUrl="" ID="g_a2fb951c_5c03_41a2_8523_ee558c68d934" ConnectionID="00000000-0000-0000-0000-000000000000" AllowZoneChange="True" TitleUrl="/tupolev/Lists/_2" IsIncludedFilter="" __MarkupType="vsattributemarkup" __WebPartId="{A2FB951C-5C03-41A2-8523-EE558C68D934}" WebPart="true" Height="" Width=""><ParameterBindings>
<ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
        <ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
        <ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
        <ParameterBinding Name="ListItemId" Location="QueryString(ID)" DefaultValue="0"/>
        </ParameterBindings>
<XmlDefinition>
<UserControl x:Class="FormXmlToXaml.UserControl2" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:system="clr-namespace:System;assembly=mscorlib"><StackPanel x:Name="Form">
<StackPanel.Resources>
<system:String x:Key="FormMode">Display</system:String>
<system:String x:Key="FormType">ListForm</system:String>
</StackPanel.Resources>
<StackPanel x:Name="MainSections"><Grid><Grid.ColumnDefinitions>
<ColumnDefinition Style="{StaticResource ms-formlabel}"/>
<ColumnDefinition Style="{StaticResource ms-formbody}"/>
</Grid.ColumnDefinitions><Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<SharePoint:FieldLabel Grid.Column="0" Grid.Row="0" ControlMode="Display" FieldName="Id" />
<Comment FieldName="Id" FieldInternalName="Id" FieldType="Text" />
<SharePoint:FormField Grid.Column="1" Grid.Row="0" ControlMode="Display" FieldName="Id" IncludeDescription="True"/>
<SharePoint:FieldLabel Grid.Column="0" Grid.Row="1" ControlMode="Display" FieldName="FirstName" />
<Comment FieldName="FirstName" FieldInternalName="FirstName" FieldType="Text" />
<SharePoint:FormField Grid.Column="1" Grid.Row="1" ControlMode="Display" FieldName="FirstName" IncludeDescription="True"/>
<SharePoint:FieldLabel Grid.Column="0" Grid.Row="2" ControlMode="Display" FieldName="SurName" />
<Comment FieldName="SurName" FieldInternalName="SurName" FieldType="Text" />
<SharePoint:FormField Grid.Column="1" Grid.Row="2" ControlMode="Display" FieldName="SurName" IncludeDescription="True"/>
<SharePoint:FieldLabel Grid.Column="0" Grid.Row="3" ControlMode="Display" FieldName="LastName" />
<Comment FieldName="LastName" FieldInternalName="LastName" FieldType="Text" />
<SharePoint:FormField Grid.Column="1" Grid.Row="3" ControlMode="Display" FieldName="LastName" IncludeDescription="True"/>
<SharePoint:FieldLabel Grid.Column="0" Grid.Row="4" ControlMode="Display" FieldName="Position" />
<Comment FieldName="Position" FieldInternalName="Position" FieldType="Text" />
<SharePoint:FormField Grid.Column="1" Grid.Row="4" ControlMode="Display" FieldName="Position" IncludeDescription="True"/>
<SharePoint:FieldLabel Grid.Column="0" Grid.Row="5" ControlMode="Display" FieldName="Company" />
<Comment FieldName="Company" FieldInternalName="Company" FieldType="Text" />
<SharePoint:FormField Grid.Column="1" Grid.Row="5" ControlMode="Display" FieldName="Company" IncludeDescription="True"/>
<SharePoint:FieldLabel Grid.Column="0" Grid.Row="6" ControlMode="Display" FieldName="WorkPhone" />
<Comment FieldName="WorkPhone" FieldInternalName="WorkPhone" FieldType="Text" />
<SharePoint:FormField Grid.Column="1" Grid.Row="6" ControlMode="Display" FieldName="WorkPhone" IncludeDescription="True"/>
<SharePoint:FieldLabel Grid.Column="0" Grid.Row="7" ControlMode="Display" FieldName="CellPhone" />
<Comment FieldName="CellPhone" FieldInternalName="CellPhone" FieldType="Text" />
<SharePoint:FormField Grid.Column="1" Grid.Row="7" ControlMode="Display" FieldName="CellPhone" IncludeDescription="True"/>
<SharePoint:FieldLabel Grid.Column="0" Grid.Row="8" ControlMode="Display" FieldName="WorkFax" />
<Comment FieldName="WorkFax" FieldInternalName="WorkFax" FieldType="Text" />
<SharePoint:FormField Grid.Column="1" Grid.Row="8" ControlMode="Display" FieldName="WorkFax" IncludeDescription="True"/>
<SharePoint:FieldLabel Grid.Column="0" Grid.Row="9" ControlMode="Display" FieldName="BithDate" />
<Comment FieldName="BithDate" FieldInternalName="BithDate" FieldType="Text" />
<SharePoint:FormField Grid.Column="1" Grid.Row="9" ControlMode="Display" FieldName="BithDate" IncludeDescription="True"/>
<SharePoint:FieldLabel Grid.Column="0" Grid.Row="10" ControlMode="Display" FieldName="BithYear" />
<Comment FieldName="BithYear" FieldInternalName="BithYear" FieldType="Text" />
<SharePoint:FormField Grid.Column="1" Grid.Row="10" ControlMode="Display" FieldName="BithYear" IncludeDescription="True"/>
<SharePoint:FieldLabel Grid.Column="0" Grid.Row="11" ControlMode="Display" FieldName="SynchState" />
<Comment FieldName="SynchState" FieldInternalName="SynchState" FieldType="Text" />
<SharePoint:FormField Grid.Column="1" Grid.Row="11" ControlMode="Display" FieldName="SynchState" IncludeDescription="True"/>
</Grid>
</StackPanel>
</StackPanel>
</UserControl></XmlDefinition>
<DataFields>
</DataFields>
</WebPartPages:XsltListFormWebPart>
share|improve this question

2 Answers 2

LOL and WOW! It works and I have no words for it :)

I added one more ColumnDefinition and added Button. And it works for SharePoint Designer form edit preview as well as for SharePoint disp web page.

So, any ideas about that fact? I haven't enough time to do more research so have a lot of fun, guys.

<UserControl x:Class="FormXmlToXaml.UserControl2" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:system="clr-namespace:System;assembly=mscorlib"><StackPanel x:Name="Form">
<StackPanel.Resources>
<system:String x:Key="FormMode">Display</system:String>
<system:String x:Key="FormType">ListForm</system:String>
</StackPanel.Resources>
<StackPanel x:Name="MainSections"><Grid><Grid.ColumnDefinitions>
<ColumnDefinition Style="{StaticResource ms-formlabel}"/>
<ColumnDefinition Style="{StaticResource ms-formbody}"/>
<ColumnDefinition Style="{StaticResource ms-formbody}"/>
</Grid.ColumnDefinitions><Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<SharePoint:FieldLabel Grid.Column="0" Grid.Row="0" ControlMode="Display" FieldName="Id" />
<Comment FieldName="Id" FieldInternalName="Id" FieldType="Integer" />
<SharePoint:FormField Grid.Column="1" Grid.Row="0" ControlMode="Display" FieldName="Id" IncludeDescription="True"/>
<SharePoint:FieldLabel Grid.Column="0" Grid.Row="1" ControlMode="Display" FieldName="Name" />
<Comment FieldName="Name" FieldInternalName="Name" FieldType="Text" />
<SharePoint:FormField Grid.Column="1" Grid.Row="1" ControlMode="Display" FieldName="Name" IncludeDescription="True"/>
<Button Content="Click Me" Grid.Column="2" Grid.Row="1" />
</Grid>
</StackPanel>
</StackPanel>
</UserControl>
share|improve this answer

Just a guess, but it may well take any valid xaml statement in between the UserControl elements. Try something like the following:

<UserControl ...attributes...>
  <StackPanel>
    <Button Content="Click Me"/>
  </StackPanel>
</UserControl>

If that works, then you might just have found a clever way of injecting XAML into a page without creating a Silverlight app.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.