I ran into an error that states "XPath failed due to: A sequence of more than one item is not allowed as the first argument of contains()('string1', 'string2')" when I'm trying to use contain to find one string inside a sequence.
My code is related to resolving my other question
https://stackoverflow.com/questions/9006479/with-pmd-and-xpath-can-i-determine-if-two-node-sets-have-any-node-in-common
Expression/PrimaryExpression/PrimaryPrefix
[
contains(ancestor::ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/FieldDeclaration/VariableDeclarator/VariableDeclaratorId/#Image,./Name/#Image)
]
I ran into this issue because VariableDeclaratorId/#Image returns two string when there are multiple fields to parse. I haven't found solution to resolve this. I thought about using predicates, but this contains is inside of a predicate already, doing VariableDeclaratorId/#Image[./Name/#Image] wouldn't work because this [./Name/#Image] is different from PrimaryPrefix/Name/#Image.
Expected Output:
<Expression BeginColumn="26" BeginLine="6" EndColumn="30" EndLine="6" Image="" Label="">
<PrimaryExpression BeginColumn="26" BeginLine="6" EndColumn="30" EndLine="6" Image="" Label="">
<PrimaryPrefix BeginColumn="26" BeginLine="6" EndColumn="30" EndLine="6" Image="" Label="" SuperModifier="false" ThisModifier="false">
<Name BeginColumn="26" BeginLine="6" EndColumn="30" EndLine="6" Image="m_foo" Label=""/>
</PrimaryPrefix>
</PrimaryExpression>
</Expression>
<Expression BeginColumn="26" BeginLine="7" EndColumn="30" EndLine="7" Image="" Label="">
<PrimaryExpression BeginColumn="26" BeginLine="7" EndColumn="30" EndLine="7" Image="" Label="">
<PrimaryPrefix BeginColumn="26" BeginLine="7" EndColumn="30" EndLine="7" Image="" Label="" SuperModifier="false" ThisModifier="false">
<Name BeginColumn="26" BeginLine="7" EndColumn="30" EndLine="7" Image="m_two" Label=""/>
</PrimaryPrefix>
</PrimaryExpression>
</Expression>
Jave Source:
public class domainFunction {
private int m_foo; // OK
public void bar() {
calculate (random);
System.out.println(m_foo);
System.out.println(m_two);
}
}
RAW XML:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<CompilationUnit BeginColumn="1" BeginLine="1" EndColumn="3" EndLine="13" Image="" Label="" declarationsAreInDefaultPackage="true">
<TypeDeclaration BeginColumn="1" BeginLine="1" EndColumn="3" EndLine="13" Image="" Label="">
<ClassOrInterfaceDeclaration Abstract="false" BeginColumn="8" BeginLine="1" EndColumn="3" EndLine="13" Final="false" Image="domainFunction" Interface="false" Label="" Modifiers="1" Native="false" Nested="false" PackagePrivate="false" Private="false" Protected="false" Public="true" Static="false" Strictfp="false" Synchronized="false" Transient="false" Volatile="false">
<ClassOrInterfaceBody BeginColumn="29" BeginLine="1" EndColumn="3" EndLine="13" Image="" Label="">
<ClassOrInterfaceBodyDeclaration AnonymousInnerClass="false" BeginColumn="5" BeginLine="2" EndColumn="22" EndLine="2" EnumChild="false" Image="" Label="">
<FieldDeclaration Abstract="false" Array="false" ArrayDepth="0" BeginColumn="13" BeginLine="2" EndColumn="22" EndLine="2" Final="false" Image="" InterfaceMember="false" Label="" Modifiers="4" Native="false" PackagePrivate="false" Private="true" Protected="false" Public="false" Static="false" Strictfp="false" Synchronized="false" SyntacticallyFinal="false" SyntacticallyPublic="false" SyntacticallyStatic="false" Transient="false" VariableName="m_foo" Volatile="false">
<Type Array="false" ArrayDepth="0" BeginColumn="13" BeginLine="2" EndColumn="15" EndLine="2" Image="" Label="" TypeImage="int">
<PrimitiveType Array="false" ArrayDepth="0" BeginColumn="13" BeginLine="2" Boolean="false" EndColumn="15" EndLine="2" Image="int" Label=""/>
</Type>
<VariableDeclarator BeginColumn="17" BeginLine="2" EndColumn="21" EndLine="2" Image="" Label="">
<VariableDeclaratorId Array="false" ArrayDepth="0" BeginColumn="17" BeginLine="2" EndColumn="21" EndLine="2" ExceptionBlockParameter="false" Image="m_foo" Label=""/>
</VariableDeclarator>
</FieldDeclaration>
</ClassOrInterfaceBodyDeclaration>
<ClassOrInterfaceBodyDeclaration AnonymousInnerClass="false" BeginColumn="5" BeginLine="3" EndColumn="22" EndLine="3" EnumChild="false" Image="" Label="">
<FieldDeclaration Abstract="false" Array="false" ArrayDepth="0" BeginColumn="13" BeginLine="3" EndColumn="22" EndLine="3" Final="false" Image="" InterfaceMember="false" Label="" Modifiers="4" Native="false" PackagePrivate="false" Private="true" Protected="false" Public="false" Static="false" Strictfp="false" Synchronized="false" SyntacticallyFinal="false" SyntacticallyPublic="false" SyntacticallyStatic="false" Transient="false" VariableName="m_two" Volatile="false">
<Type Array="false" ArrayDepth="0" BeginColumn="13" BeginLine="3" EndColumn="15" EndLine="3" Image="" Label="" TypeImage="int">
<PrimitiveType Array="false" ArrayDepth="0" BeginColumn="13" BeginLine="3" Boolean="false" EndColumn="15" EndLine="3" Image="int" Label=""/>
</Type>
<VariableDeclarator BeginColumn="17" BeginLine="3" EndColumn="21" EndLine="3" Image="" Label="">
<VariableDeclaratorId Array="false" ArrayDepth="0" BeginColumn="17" BeginLine="3" EndColumn="21" EndLine="3" ExceptionBlockParameter="false" Image="m_two" Label=""/>
</VariableDeclarator>
</FieldDeclaration>
</ClassOrInterfaceBodyDeclaration>
<ClassOrInterfaceBodyDeclaration AnonymousInnerClass="false" BeginColumn="5" BeginLine="4" EndColumn="5" EndLine="11" EnumChild="false" Image="" Label="">
<MethodDeclaration Abstract="false" BeginColumn="12" BeginLine="4" EndColumn="5" EndLine="11" Final="false" Image="" InterfaceMember="false" Label="" MethodName="bar" Modifiers="1" Native="false" PackagePrivate="false" Private="false" Protected="false" Public="true" Static="false" Strictfp="false" Synchronized="false" SyntacticallyAbstract="false" SyntacticallyPublic="true" Transient="false" Void="true" Volatile="false">
<ResultType BeginColumn="12" BeginLine="4" EndColumn="15" EndLine="4" Image="" Label="" Void="true" returnsArray="false"/>
<MethodDeclarator BeginColumn="17" BeginLine="4" EndColumn="21" EndLine="4" Image="bar" Label="" ParameterCount="0">
<FormalParameters BeginColumn="20" BeginLine="4" EndColumn="21" EndLine="4" Image="" Label="" ParameterCount="0"/>
</MethodDeclarator>
<Block BeginColumn="23" BeginLine="4" EndColumn="5" EndLine="11" Image="" Label="" containsComment="false">
<BlockStatement Allocation="false" BeginColumn="7" BeginLine="5" EndColumn="22" EndLine="5" Image="" Label="">
<LocalVariableDeclaration Abstract="false" Array="false" ArrayDepth="0" BeginColumn="7" BeginLine="5" EndColumn="21" EndLine="5" Final="false" Image="" Label="" Modifiers="0" Native="false" PackagePrivate="true" Private="false" Protected="false" Public="false" Static="false" Strictfp="false" Synchronized="false" Transient="false" VariableName="random" Volatile="false">
<Type Array="false" ArrayDepth="0" BeginColumn="7" BeginLine="5" EndColumn="9" EndLine="5" Image="" Label="" TypeImage="int">
<PrimitiveType Array="false" ArrayDepth="0" BeginColumn="7" BeginLine="5" Boolean="false" EndColumn="9" EndLine="5" Image="int" Label=""/>
</Type>
<VariableDeclarator BeginColumn="11" BeginLine="5" EndColumn="21" EndLine="5" Image="" Label="">
<VariableDeclaratorId Array="false" ArrayDepth="0" BeginColumn="11" BeginLine="5" EndColumn="16" EndLine="5" ExceptionBlockParameter="false" Image="random" Label=""/>
<VariableInitializer BeginColumn="20" BeginLine="5" EndColumn="21" EndLine="5" Image="" Label="">
<Expression BeginColumn="20" BeginLine="5" EndColumn="21" EndLine="5" Image="" Label="">
<PrimaryExpression BeginColumn="20" BeginLine="5" EndColumn="21" EndLine="5" Image="" Label="">
<PrimaryPrefix BeginColumn="20" BeginLine="5" EndColumn="21" EndLine="5" Image="" Label="" SuperModifier="false" ThisModifier="false">
<Literal BeginColumn="20" BeginLine="5" CharLiteral="false" EndColumn="21" EndLine="5" FloatLiteral="false" Image="12" IntLiteral="true" Label="" SingleCharacterStringLiteral="false" StringLiteral="false"/>
</PrimaryPrefix>
</PrimaryExpression>
</Expression>
</VariableInitializer>
</VariableDeclarator>
</LocalVariableDeclaration>
</BlockStatement>
<BlockStatement Allocation="false" BeginColumn="7" BeginLine="6" EndColumn="25" EndLine="6" Image="" Label="">
<Statement BeginColumn="7" BeginLine="6" EndColumn="25" EndLine="6" Image="" Label="">
<StatementExpression BeginColumn="7" BeginLine="6" EndColumn="24" EndLine="6" Image="" Label="">
<PrimaryExpression BeginColumn="7" BeginLine="6" EndColumn="24" EndLine="6" Image="" Label="">
<PrimaryPrefix BeginColumn="7" BeginLine="6" EndColumn="15" EndLine="6" Image="" Label="" SuperModifier="false" ThisModifier="false">
<Name BeginColumn="7" BeginLine="6" EndColumn="15" EndLine="6" Image="calculate" Label=""/>
</PrimaryPrefix>
<PrimarySuffix ArgumentCount="1" Arguments="true" ArrayDereference="false" BeginColumn="17" BeginLine="6" EndColumn="24" EndLine="6" Image="" Label="">
<Arguments ArgumentCount="1" BeginColumn="17" BeginLine="6" EndColumn="24" EndLine="6" Image="" Label="">
<ArgumentList BeginColumn="18" BeginLine="6" EndColumn="23" EndLine="6" Image="" Label="">
<Expression BeginColumn="18" BeginLine="6" EndColumn="23" EndLine="6" Image="" Label="">
<PrimaryExpression BeginColumn="18" BeginLine="6" EndColumn="23" EndLine="6" Image="" Label="">
<PrimaryPrefix BeginColumn="18" BeginLine="6" EndColumn="23" EndLine="6" Image="" Label="" SuperModifier="false" ThisModifier="false">
<Name BeginColumn="18" BeginLine="6" EndColumn="23" EndLine="6" Image="random" Label=""/>
</PrimaryPrefix>
</PrimaryExpression>
</Expression>
</ArgumentList>
</Arguments>
</PrimarySuffix>
</PrimaryExpression>
</StatementExpression>
</Statement>
</BlockStatement>
<BlockStatement Allocation="false" BeginColumn="7" BeginLine="7" EndColumn="24" EndLine="7" Image="" Label="">
<Statement BeginColumn="7" BeginLine="7" EndColumn="24" EndLine="7" Image="" Label="">
<StatementExpression BeginColumn="7" BeginLine="7" EndColumn="23" EndLine="7" Image="" Label="">
<PrimaryExpression BeginColumn="7" BeginLine="7" EndColumn="23" EndLine="7" Image="" Label="">
<PrimaryPrefix BeginColumn="7" BeginLine="7" EndColumn="15" EndLine="7" Image="" Label="" SuperModifier="false" ThisModifier="false">
<Name BeginColumn="7" BeginLine="7" EndColumn="15" EndLine="7" Image="calculate" Label=""/>
</PrimaryPrefix>
<PrimarySuffix ArgumentCount="1" Arguments="true" ArrayDereference="false" BeginColumn="17" BeginLine="7" EndColumn="23" EndLine="7" Image="" Label="">
<Arguments ArgumentCount="1" BeginColumn="17" BeginLine="7" EndColumn="23" EndLine="7" Image="" Label="">
<ArgumentList BeginColumn="18" BeginLine="7" EndColumn="22" EndLine="7" Image="" Label="">
<Expression BeginColumn="18" BeginLine="7" EndColumn="22" EndLine="7" Image="" Label="">
<PrimaryExpression BeginColumn="18" BeginLine="7" EndColumn="22" EndLine="7" Image="" Label="">
<PrimaryPrefix BeginColumn="18" BeginLine="7" EndColumn="22" EndLine="7" Image="" Label="" SuperModifier="false" ThisModifier="false">
<Name BeginColumn="18" BeginLine="7" EndColumn="22" EndLine="7" Image="m_foo" Label=""/>
</PrimaryPrefix>
</PrimaryExpression>
</Expression>
</ArgumentList>
</Arguments>
</PrimarySuffix>
</PrimaryExpression>
</StatementExpression>
</Statement>
</BlockStatement>
<BlockStatement Allocation="false" BeginColumn="7" BeginLine="8" EndColumn="32" EndLine="8" Image="" Label="">
<Statement BeginColumn="7" BeginLine="8" EndColumn="32" EndLine="8" Image="" Label="">
<StatementExpression BeginColumn="7" BeginLine="8" EndColumn="31" EndLine="8" Image="" Label="">
<PrimaryExpression BeginColumn="7" BeginLine="8" EndColumn="31" EndLine="8" Image="" Label="">
<PrimaryPrefix BeginColumn="7" BeginLine="8" EndColumn="24" EndLine="8" Image="" Label="" SuperModifier="false" ThisModifier="false">
<Name BeginColumn="7" BeginLine="8" EndColumn="24" EndLine="8" Image="System.out.println" Label=""/>
</PrimaryPrefix>
<PrimarySuffix ArgumentCount="1" Arguments="true" ArrayDereference="false" BeginColumn="25" BeginLine="8" EndColumn="31" EndLine="8" Image="" Label="">
<Arguments ArgumentCount="1" BeginColumn="25" BeginLine="8" EndColumn="31" EndLine="8" Image="" Label="">
<ArgumentList BeginColumn="26" BeginLine="8" EndColumn="30" EndLine="8" Image="" Label="">
<Expression BeginColumn="26" BeginLine="8" EndColumn="30" EndLine="8" Image="" Label="">
<PrimaryExpression BeginColumn="26" BeginLine="8" EndColumn="30" EndLine="8" Image="" Label="">
<PrimaryPrefix BeginColumn="26" BeginLine="8" EndColumn="30" EndLine="8" Image="" Label="" SuperModifier="false" ThisModifier="false">
<Name BeginColumn="26" BeginLine="8" EndColumn="30" EndLine="8" Image="m_foo" Label=""/>
</PrimaryPrefix>
</PrimaryExpression>
</Expression>
</ArgumentList>
</Arguments>
</PrimarySuffix>
</PrimaryExpression>
</StatementExpression>
</Statement>
</BlockStatement>
<BlockStatement Allocation="false" BeginColumn="7" BeginLine="9" EndColumn="32" EndLine="9" Image="" Label="">
<Statement BeginColumn="7" BeginLine="9" EndColumn="32" EndLine="9" Image="" Label="">
<StatementExpression BeginColumn="7" BeginLine="9" EndColumn="31" EndLine="9" Image="" Label="">
<PrimaryExpression BeginColumn="7" BeginLine="9" EndColumn="31" EndLine="9" Image="" Label="">
<PrimaryPrefix BeginColumn="7" BeginLine="9" EndColumn="24" EndLine="9" Image="" Label="" SuperModifier="false" ThisModifier="false">
<Name BeginColumn="7" BeginLine="9" EndColumn="24" EndLine="9" Image="System.out.println" Label=""/>
</PrimaryPrefix>
<PrimarySuffix ArgumentCount="1" Arguments="true" ArrayDereference="false" BeginColumn="25" BeginLine="9" EndColumn="31" EndLine="9" Image="" Label="">
<Arguments ArgumentCount="1" BeginColumn="25" BeginLine="9" EndColumn="31" EndLine="9" Image="" Label="">
<ArgumentList BeginColumn="26" BeginLine="9" EndColumn="30" EndLine="9" Image="" Label="">
<Expression BeginColumn="26" BeginLine="9" EndColumn="30" EndLine="9" Image="" Label="">
<PrimaryExpression BeginColumn="26" BeginLine="9" EndColumn="30" EndLine="9" Image="" Label="">
<PrimaryPrefix BeginColumn="26" BeginLine="9" EndColumn="30" EndLine="9" Image="" Label="" SuperModifier="false" ThisModifier="false">
<Name BeginColumn="26" BeginLine="9" EndColumn="30" EndLine="9" Image="m_two" Label=""/>
</PrimaryPrefix>
</PrimaryExpression>
</Expression>
</ArgumentList>
</Arguments>
</PrimarySuffix>
</PrimaryExpression>
</StatementExpression>
</Statement>
</BlockStatement>
<BlockStatement Allocation="false" BeginColumn="7" BeginLine="10" EndColumn="28" EndLine="10" Image="" Label="">
<Statement BeginColumn="7" BeginLine="10" EndColumn="28" EndLine="10" Image="" Label="">
<StatementExpression BeginColumn="7" BeginLine="10" EndColumn="27" EndLine="10" Image="" Label="">
<PrimaryExpression BeginColumn="7" BeginLine="10" EndColumn="27" EndLine="10" Image="" Label="">
<PrimaryPrefix BeginColumn="7" BeginLine="10" EndColumn="10" EndLine="10" Image="" Label="this" SuperModifier="false" ThisModifier="true"/>
<PrimarySuffix ArgumentCount="" Arguments="false" ArrayDereference="false" BeginColumn="11" BeginLine="10" EndColumn="20" EndLine="10" Image="calculate" Label=""/>
<PrimarySuffix ArgumentCount="1" Arguments="true" ArrayDereference="false" BeginColumn="21" BeginLine="10" EndColumn="27" EndLine="10" Image="" Label="">
<Arguments ArgumentCount="1" BeginColumn="21" BeginLine="10" EndColumn="27" EndLine="10" Image="" Label="">
<ArgumentList BeginColumn="22" BeginLine="10" EndColumn="26" EndLine="10" Image="" Label="">
<Expression BeginColumn="22" BeginLine="10" EndColumn="26" EndLine="10" Image="" Label="">
<PrimaryExpression BeginColumn="22" BeginLine="10" EndColumn="26" EndLine="10" Image="" Label="">
<PrimaryPrefix BeginColumn="22" BeginLine="10" EndColumn="26" EndLine="10" Image="" Label="" SuperModifier="false" ThisModifier="false">
<Name BeginColumn="22" BeginLine="10" EndColumn="26" EndLine="10" Image="m_foo" Label=""/>
</PrimaryPrefix>
</PrimaryExpression>
</Expression>
</ArgumentList>
</Arguments>
</PrimarySuffix>
</PrimaryExpression>
</StatementExpression>
</Statement>
</BlockStatement>
</Block>
</MethodDeclaration>
</ClassOrInterfaceBodyDeclaration>
</ClassOrInterfaceBody>
</ClassOrInterfaceDeclaration>
</TypeDeclaration>
</CompilationUnit>
I think you are using the contains() function because you have guessed incorrectly that it tests whether a set of strings contains a given string. Don't guess, read the spec: that's not what contains() does; rather, it tests whether one string contains another as a substring. To test whether a set of strings $S contains a string $T, use ($S = $T).
Related
i have a view which contains entry fields kept inside the scrollView,here when i tapped on entry field the keyboard popups and covers the remaining fields,by following this i couldnt able to solve my problem.i chnged my main activity as [Activity(Label = "MyApp", Icon = "#drawable/icon", Theme = "#style/MainTheme", MainLauncher = false, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, WindowSoftInputMode = SoftInput.AdjustResize)] and also checked for AdjustPan nothing worked,how to scroll those fields upto last field when keyboardpopups?
<ContentView>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ScrollView Orientation="Vertical">
<StackLayout Grid.Row="0" HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand" Padding="10">
<StackLayout.Spacing>
<OnIdiom x:TypeArguments ="x:Double" Phone = "8" Tablet ="16"/>
</StackLayout.Spacing>
<Entry x:Name="FirstNameEntry" PlaceholderColor="#9E9E9E" Text="{Binding FirstName}" Placeholder="First name" HorizontalOptions="FillAndExpand" TextColor="#191919" FontFamily="Avenir Book">
<Entry.HeightRequest>
<OnIdiom x:TypeArguments="x:Double">
<OnIdiom.Phone>
<OnPlatform x:TypeArguments="x:Double" iOS="30" Android="40" WinPhone="28" />
</OnIdiom.Phone>
<OnIdiom.Tablet>
<OnPlatform x:TypeArguments="x:Double" iOS="40" Android="45" WinPhone="28" />
</OnIdiom.Tablet>
</OnIdiom>
</Entry.HeightRequest>
</Entry>
<Entry x:Name="LastNameEntry" Text="{Binding LastName}" PlaceholderColor = "#9E9E9E" Placeholder="Last name" HorizontalOptions="FillAndExpand" TextColor="#191919" FontFamily="Avenir Book">
<Entry.HeightRequest>
<OnIdiom x:TypeArguments="x:Double">
<OnIdiom.Phone>
<OnPlatform x:TypeArguments="x:Double" iOS="30" Android="40" WinPhone="28" />
</OnIdiom.Phone>
<OnIdiom.Tablet>
<OnPlatform x:TypeArguments="x:Double" iOS="40" Android="45" WinPhone="28" />
</OnIdiom.Tablet>
</OnIdiom>
</Entry.HeightRequest>
</Entry>
<Entry x:Name="MobileNameEntry" Keyboard="Numeric" PlaceholderColor="#9E9E9E" Text="{Binding MobileNumber}" TextChanged = "On_PhoneNumberTextChanged" Placeholder="Mobile number" HorizontalOptions="FillAndExpand" TextColor="#191919" FontFamily="Avenir Book">
<Entry.HeightRequest>
<OnIdiom x:TypeArguments="x:Double">
<OnIdiom.Phone>
<OnPlatform x:TypeArguments="x:Double" iOS="30" Android="40" WinPhone="28" />
</OnIdiom.Phone>
<OnIdiom.Tablet>
<OnPlatform x:TypeArguments="x:Double" iOS="40" Android="45" WinPhone="28" />
</OnIdiom.Tablet>
</OnIdiom>
</Entry.HeightRequest>
</Entry>
<Entry x:Name="HouseNumberEntry" Text="{Binding HouseNumber}" PlaceholderColor="#9E9E9E" Placeholder="House number" HorizontalOptions="FillAndExpand" TextColor="#191919" FontFamily="Avenir Book">
<Entry.HeightRequest>
<OnIdiom x:TypeArguments="x:Double">
<OnIdiom.Phone>
<OnPlatform x:TypeArguments="x:Double" iOS="30" Android="40" WinPhone="28" />
</OnIdiom.Phone>
<OnIdiom.Tablet>
<OnPlatform x:TypeArguments="x:Double" iOS="40" Android="45" WinPhone="28" />
</OnIdiom.Tablet>
</OnIdiom>
</Entry.HeightRequest>
</Entry>
<Entry x:Name="StreetNameEntry" Text="{Binding StreetName}" PlaceholderColor="#9E9E9E" Placeholder="Street name" HorizontalOptions="FillAndExpand" TextColor="#191919" FontFamily="Avenir Book">
<Entry.HeightRequest>
<OnIdiom x:TypeArguments="x:Double">
<OnIdiom.Phone>
<OnPlatform x:TypeArguments="x:Double" iOS="30" Android="40" WinPhone="28" />
</OnIdiom.Phone>
<OnIdiom.Tablet>
<OnPlatform x:TypeArguments="x:Double" iOS="40" Android="45" WinPhone="28" />
</OnIdiom.Tablet>
</OnIdiom>
</Entry.HeightRequest>
</Entry>
<Entry x:Name="CityNameEntry" Text="{Binding City}" PlaceholderColor="#9E9E9E" Placeholder="City" HorizontalOptions="FillAndExpand" TextColor="#191919" FontFamily="Avenir Book">
<Entry.HeightRequest>
<OnIdiom x:TypeArguments="x:Double">
<OnIdiom.Phone>
<OnPlatform x:TypeArguments="x:Double" iOS="30" Android="40" WinPhone="28" />
</OnIdiom.Phone>
<OnIdiom.Tablet>
<OnPlatform x:TypeArguments="x:Double" iOS="40" Android="45" WinPhone="28" />
</OnIdiom.Tablet>
</OnIdiom>
</Entry.HeightRequest>
</Entry>
<Entry x:Name="PostCodeEntry" Text="{Binding PostalCode}" PlaceholderColor="#9E9E9E" Placeholder="Post code" HorizontalOptions="FillAndExpand" TextColor="#191919" FontFamily="Avenir Book">
<Entry.HeightRequest>
<OnIdiom x:TypeArguments="x:Double">
<OnIdiom.Phone>
<OnPlatform x:TypeArguments="x:Double" iOS="30" Android="40" WinPhone="28" />
</OnIdiom.Phone>
<OnIdiom.Tablet>
<OnPlatform x:TypeArguments="x:Double" iOS="40" Android="45" WinPhone="28" />
</OnIdiom.Tablet>
</OnIdiom>
</Entry.HeightRequest>
</Entry>
<Picker x:Name="AddressTypePicker" Title="Select type" HorizontalOptions="FillAndExpand" SelectedIndexChanged="AddressTypePicker_OnSelectedIndexChanged">
<Picker.HeightRequest>
<OnIdiom x:TypeArguments="x:Double">
<OnIdiom.Phone>
<OnPlatform x:TypeArguments="x:Double" iOS="30" Android="40" WinPhone="28" />
</OnIdiom.Phone>
<OnIdiom.Tablet>
<OnPlatform x:TypeArguments="x:Double" iOS="40" Android="45" WinPhone="28" />
</OnIdiom.Tablet>
</OnIdiom>
</Picker.HeightRequest>
</Picker>
</StackLayout>
</ScrollView>
<StackLayout BackgroundColor="#f2c646" Grid.Row="1" Orientation="Horizontal" HorizontalOptions="FillAndExpand" VerticalOptions="End" Padding="0">
<StackLayout.HeightRequest>
<OnIdiom x:TypeArguments="x:Double">
<OnIdiom.Phone>
<OnPlatform x:TypeArguments="x:Double" iOS="40" Android="50" WinPhone="28" />
</OnIdiom.Phone>
<OnIdiom.Tablet>
<OnPlatform x:TypeArguments="x:Double" iOS="50" Android="60" WinPhone="28" />
</OnIdiom.Tablet>
</OnIdiom>
</StackLayout.HeightRequest>
<StackLayout Padding="10">
<Label Text="Cancel" TextColor="Black" HorizontalOptions="StartAndExpand" FontFamily="Avenir Book" VerticalTextAlignment="Center">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="OnCancelBtnClicked"/>
</Label.GestureRecognizers>
<Label.FontSize>
<OnIdiom x:TypeArguments="x:Double">
<OnIdiom.Phone>
<OnPlatform x:TypeArguments="x:Double" iOS="15" Android="17" WinPhone="28" />
</OnIdiom.Phone>
<OnIdiom.Tablet>
<OnPlatform x:TypeArguments="x:Double" iOS="20" Android="22" WinPhone="28" />
</OnIdiom.Tablet>
</OnIdiom>
</Label.FontSize>
</Label>
</StackLayout>
<StackLayout HorizontalOptions="EndAndExpand" Padding="10">
<Label Text="Save" TextColor="Black" VerticalTextAlignment="Center" FontFamily="Avenir Book">
<Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding SaveCommand}"/>
</Label.GestureRecognizers>
<Label.FontSize>
<OnIdiom x:TypeArguments="x:Double">
<OnIdiom.Phone>
<OnPlatform x:TypeArguments="x:Double" iOS="15" Android="17" WinPhone="28" />
</OnIdiom.Phone>
<OnIdiom.Tablet>
<OnPlatform x:TypeArguments="x:Double" iOS="20" Android="22" WinPhone="28" />
</OnIdiom.Tablet>
</OnIdiom>
</Label.FontSize>
</Label>
</StackLayout>
</StackLayout>
</Grid>
I believe you have a situation of signup form. Why don't you use tableview with Intent="Form" as table view has a built-in scroller which can accommodate for keep-entry-in-view behaviour. It gives native look of a form as well.
I used it in one of my projects and it worked perfectly on both iOS and Android.
<TableView Intent="Form" HasUnevenRows="true">
</TableView>
Reference: TableView
Hope this helps
Telerik rad grid header TextWraping is not working but its working for all other rows except header in Silverlight-Ui
image attached .. the TextWraping not working for header row
xaml code
<Style x:Key="ColumnHeaderGripperStyle" TargetType="Thumb">
<Setter Property="Width" Value="8"/>
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="Padding" Value="0" />
<Setter Property="Cursor" Value="SizeWE"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Thumb">
<Border Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="ContentControl" x:Key="StretchedContentControl">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
</Style>
<ControlTemplate x:Key="GridViewHeaderCellTemplate" TargetType="telerik:GridViewHeaderCell">
<Grid x:Name="PART_HeaderCellGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="30" />
</Grid.ColumnDefinitions>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="00:00:00.2000000" To="Normal" />
<VisualTransition GeneratedDuration="00:00:00.2000000" To="MouseOver" />
<VisualTransition GeneratedDuration="0:0:0.2" To="Pressed"/>
</VisualStateGroup.Transitions>
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="GridViewHeaderCell_Over" Storyboard.TargetProperty="Opacity">
<EasingDoubleKeyFrame KeyTime="0:0:0" Value="1"/>
</DoubleAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource GridView_HeaderForeground_Selected}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Ascending">
<Storyboard>
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource GridView_HeaderForeground_Selected}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_SortIndicator" Storyboard.TargetProperty="Opacity">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="1" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GridViewHeaderCell_Selected" Storyboard.TargetProperty="Opacity">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="1"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Descending">
<Storyboard>
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource GridView_HeaderForeground_Selected}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_SortIndicator" Storyboard.TargetProperty="Opacity">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="1" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_SortIndicator" Storyboard.TargetProperty="RenderTransform">
<DiscreteObjectKeyFrame KeyTime="0:0:0">
<DiscreteObjectKeyFrame.Value>
<ScaleTransform ScaleX="1" ScaleY="1" />
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GridViewHeaderCell_Selected" Storyboard.TargetProperty="Opacity">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="1"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border x:Name="GridViewHeaderCell" Grid.ColumnSpan="2" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Border BorderBrush="{StaticResource GridView_HeaderInnerBorder}"
Background="{TemplateBinding Background}"
BorderThickness="0" Margin="0,0,1,0"/>
</Border>
<Border x:Name="GridViewHeaderCell_Over" Grid.ColumnSpan="2"
BorderBrush="{StaticResource GridView_HeaderOuterBorder_Over}"
BorderThickness="{TemplateBinding BorderThickness}" Opacity="0" >
<Border BorderBrush="{StaticResource GridView_HeaderInnerBorder_Over}"
Background="{StaticResource GridView_HeaderBackground_Over}"
BorderThickness="0" />
</Border>
<Border x:Name="GridViewHeaderCell_Selected" Grid.ColumnSpan="2"
BorderBrush="{StaticResource GridView_HeaderOuterBorder_Selected}"
BorderThickness="{TemplateBinding BorderThickness}" Opacity="0" >
<Border BorderBrush="{StaticResource GridView_HeaderInnerBorder_Selected}"
Background="{StaticResource GridView_HeaderBackground_Selected}"
BorderThickness="0" />
</Border>
<ContentControl x:Name="ContentPresenter" Grid.Column="0" Foreground="{TemplateBinding Foreground}"
Style="{StaticResource StretchedContentControl}"
Margin="{TemplateBinding Padding}" IsTabStop="{TemplateBinding IsTabStop}"
Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
<Path x:Name="PART_SortIndicator" Grid.ColumnSpan="2"
Fill="{StaticResource GridView_SortIndicatorColor}"
Stretch="Fill" HorizontalAlignment="Center" VerticalAlignment="Top"
Margin="0,3,0,0"
Data="M0,0 L1,0 2,0 3,0 4,0 5,0 5,1 4,1 4,2 3,2 3,3 2,3 2,2 1,2 1,1 0,1 0,0 z"
Width="5" Height="3"
RenderTransformOrigin=".5,.5"
Opacity="0">
<Path.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="-1"/>
<SkewTransform AngleX="0" AngleY="0"/>
<RotateTransform Angle="0"/>
<TranslateTransform X="0" Y="0"/>
</TransformGroup>
</Path.RenderTransform>
</Path>
<telerik:FilteringDropDown x:Name="PART_DistinctFilterControl" Grid.Column="1"
Visibility="{TemplateBinding FilteringUIVisibility}"
Margin="0,0,8,0"/>
<Thumb x:Name="PART_LeftHeaderGripper" HorizontalAlignment="Left" IsTabStop="{TemplateBinding IsTabStop}" Style="{StaticResource ColumnHeaderGripperStyle}" Grid.ColumnSpan="2" />
<Thumb x:Name="PART_RightHeaderGripper" HorizontalAlignment="Right" IsTabStop="{TemplateBinding IsTabStop}" Style="{StaticResource ColumnHeaderGripperStyle}" Grid.ColumnSpan="2" />
</Grid>
</ControlTemplate>
<Style TargetType="telerik:GridViewHeaderCell" x:Key="GridViewHeaderCellStyle">
<Setter Property="Template" Value="{StaticResource GridViewHeaderCellTemplate}" />
<Setter Property="Background" Value="{StaticResource GridView_HeaderBackground}" />
<Setter Property="BorderBrush" Value="{StaticResource GridView_HeaderOuterBorder}" />
<Setter Property="BorderThickness" Value="0,0,0,0" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="Foreground" Value="{StaticResource GridView_HeaderForeground}" />
<Setter Property="FontSize" Value="11" />
</Style>
<!-- Header Row Style-->
<SolidColorBrush x:Key="GridView_HeaderRowInnerBorder" Color="#FFFCFCFC" />
<LinearGradientBrush x:Key="GridView_HeaderRowBackground" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFDCEEFB" Offset="1"/>
<GradientStop Color="#FFDCEEFB"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="GridView_HeaderRowOuterBorder" Color="#FFC0CBD9" />
<telerik:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<DataTemplate x:Key="GridViewHeaderIndentCellDataTemplate">
<telerik:GridViewHeaderIndentCell telerik:StyleManager.Theme="{StaticResource Theme}"/>
</DataTemplate>
<ControlTemplate x:Key="GridViewHeaderRowTemplate" TargetType="telerik:GridViewHeaderRow">
<telerik:SelectiveScrollingGrid>
<telerik:SelectiveScrollingGrid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</telerik:SelectiveScrollingGrid.ColumnDefinitions>
<Border x:Name="PART_GridViewHeaderRowBorder"
BorderBrush="{TemplateBinding BorderBrush}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Padding="{TemplateBinding Padding}"
Grid.ColumnSpan="4"
BorderThickness="{TemplateBinding BorderThickness}">
<Border BorderBrush="{StaticResource GridView_HeaderRowInnerBorder}" Background="{TemplateBinding Background}" BorderThickness="0" />
</Border>
<telerik:DataCellsPresenter x:Name="PART_DataCellsPresenter"
telerik:StyleManager.Theme="{StaticResource Theme}"
Grid.Column="3" />
<Border x:Name="PART_IndicatorPresenter"
Width="25"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="0,0,1,1"
Visibility="{TemplateBinding RowIndicatorVisibility}"
telerik:SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical">
<Border BorderBrush="{StaticResource GridView_HeaderInnerBorder}" Background="{StaticResource GridView_HeaderBackground}" BorderThickness="0" />
</Border>
<telerik:IndentPresenter x:Name="PART_IndentPresenter" Grid.Column="1" MinHeight="{TemplateBinding MinHeight}"
telerik:StyleManager.Theme="{StaticResource Theme}"
IndentLevel="{TemplateBinding IndentLevel}"
ItemTemplate="{StaticResource GridViewHeaderIndentCellDataTemplate}"
telerik:SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical" />
<Border x:Name="PART_HierarchyIndentPresenter" Grid.Column="2"
Width="25"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="0,0,1,1"
Visibility="{Binding HasHierarchy, Converter={StaticResource BooleanToVisibilityConverter}, RelativeSource={RelativeSource TemplatedParent}}"
telerik:SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical">
<Border BorderBrush="{StaticResource GridView_HeaderInnerBorder}" Background="{StaticResource GridView_HeaderBackground}" BorderThickness="0" />
</Border>
</telerik:SelectiveScrollingGrid>
</ControlTemplate>
<Style TargetType="telerik:GridViewHeaderRow" x:Key="CustomHeaderRowStyle">
<Setter Property="Template" Value="{StaticResource GridViewHeaderRowTemplate}" />
<Setter Property="Background" Value="{StaticResource GridView_HeaderRowBackground}" />
<Setter Property="BorderBrush" Value="{StaticResource GridView_HeaderRowOuterBorder}" />
<Setter Property="BorderThickness" Value="0,0,0,0" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Padding" Value="0" />
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="*" />
<RowDefinition Height="auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<telerik:RadGridView IsFilteringAllowed="False" AutoGenerateColumns="True"
CanUserFreezeColumns="true" CanUserResizeColumns="True"
ShowGroupPanel="False" FrozenColumnCount="{Binding FrozenColumnCount,Source={StaticResource model}}"
ClipboardCopyMode="Cells" ClipboardPasteMode="AllSelectedCells,OverwriteWithEmptyValues,SkipHiddenColumns"
SelectionMode="Extended" SelectionUnit="Mixed"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Visible"
x:Name="RadGridView1" Grid.Column="0" Grid.Row="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ItemsSource="{Binding Data, Source={StaticResource model}}"
IsBusy="{Binding IsLoading,Source={StaticResource model}}"
CellEditEnded="RadGridView1_CellEditEnded"
CellValidating="RadGridView1_CellValidating"
PastingCellClipboardContent="RadGridView1_PastingCellClipboardContent"
AutoGeneratingColumn="RadGridView1_AutoGeneratingColumn" CanUserDeleteRows="False"
CanUserInsertRows="False" Pasted="RadGridView1_Pasted" CanUserReorderColumns="False"
CanUserSortColumns="False" BeginningEdit="RadGridView1_BeginningEdit"
CacheMode="BitmapCache" CanUserSortGroups="False" HeaderRowStyle="{StaticResource CustomHeaderRowStyle}"
ElementExporting="RadGridView1_OnElementExporting" Pasting="RadGridView1_Pasting"
DataLoaded="RadGridView1_DataLoaded"
local:ContextMenuBehavior.ContextMenu="{Binding ElementName=GridContextMenu}">
<telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu x:Name="GridContextMenu">
<telerik:RadContextMenu.Items>
<telerik:RadMenuItem Header="Lock" />
<telerik:RadMenuItem Header="Unlock" />
</telerik:RadContextMenu.Items>
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
</telerik:RadGridView>
</Grid>
</Border>
</UserControl>
how can i set the header Textwraping??
you have to add text block in headers and give the textblock.Text=col name;textblock.textwrapping=Wrap;
assingn this textblock to header while creating the radGridHeader.
I have a time picker control in xaml as
<TimePicker Time="{Binding SelectedTime, Mode=TwoWay}" HorizontalContentAlignment="Center"
Style="{StaticResource TimePickerStyle}" x:Name="SeekTimePicker" />
and of the control is
<Style x:Key="TimePickerStyle" TargetType="TimePicker">
<Setter Property="FontFamily" Value="{ThemeResource PhoneFontFamilyNormal}" />
<Setter Property="FontSize" Value="{ThemeResource ContentControlFontSize}" />
<Setter Property="Foreground" Value="{ThemeResource TimePickerForegroundThemeBrush}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TimePicker" >
<StackPanel x:Name="LayoutRoot" Margin="{TemplateBinding Padding}" Background="Red">
<ContentPresenter x:Name="HeaderContentPresenter"
ContentTemplate="{TemplateBinding HeaderTemplate}"
Content="aaaa" Margin="0,0,0,-3"
Style="{StaticResource HeaderContentPresenterStyle}" />
<Button x:Name="FlyoutButton" BorderBrush="{TemplateBinding Foreground}" BorderThickness="1"
Foreground="{TemplateBinding Foreground}" HorizontalAlignment="Stretch"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
IsEnabled="{TemplateBinding IsEnabled}" Padding="6.5,0,0,3" Content="qqqqqqqqqqqq" Background="Green"/>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Now it look like:
But I want to format it as:
This can do by editing template inside time picker style as below
<Style x:Key="TimePickerStyle" TargetType="TimePicker">
<Setter Property="FontFamily" Value="{ThemeResource PhoneFontFamilyNormal}" />
<Setter Property="FontSize" Value="{ThemeResource ContentControlFontSize}" />
<Setter Property="Foreground" Value="{ThemeResource TimePickerForegroundThemeBrush}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TimePicker">
<StackPanel x:Name="LayoutRoot" Margin="{TemplateBinding Padding}">
<ContentPresenter x:Name="HeaderContentPresenter"
ContentTemplate="{TemplateBinding HeaderTemplate}"
Content="{TemplateBinding Header}" Margin="0,0,0,-3"
Style="{StaticResource HeaderContentPresenterStyle}" />
<Button x:Name="FlyoutButton" BorderBrush="{TemplateBinding Foreground}" BorderThickness="1"
Foreground="{TemplateBinding Foreground}" HorizontalAlignment="Stretch"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
IsEnabled="{TemplateBinding IsEnabled}" Padding="6.5,0,0,3" >
<Button.ContentTemplate>
<DataTemplate>
<TextBlock Text="{Binding ElementName=FlyoutButton,Path=DataContext.SelectedTimeText}"/>
</DataTemplate>
</Button.ContentTemplate>
</Button>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
I am trying to detect if a StringBuffer is used, and if the append method is invoked or not. so, my approach is as given below. But I am yet to find a solution.
Looking forward for help.
xPath prepared :
//PrimaryExpression/PrimaryPrefix/Name[contains(#Image,'append') and contains(#Image,
//LocalVariableDeclaration[descendant::ClassOrInterfaceType[#Image='StringBuffer']]
/VariableDeclarator/VariableDeclaratorId/#Image)]
test Input
public class pmdTestSomeCollection {
StringBuffer sb11 = new StringBuffer("abcdeeee");
public static void main(String args[]) {
StringBuffer sb1 = new StringBuffer("abcde");
sb1.append("abcdefghij");
StringBuffer sb2 = sb1.reverse();
sb2.append("A");
System.out.println(sb1);
System.out.println(sb2);
}
}
XML generated (Abstract Syntax Tree)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<CompilationUnit BeginColumn="1" BeginLine="1" EndColumn="1" EndLine="10" Image="" Label="" declarationsAreInDefaultPackage="true">
<TypeDeclaration BeginColumn="1" BeginLine="1" EndColumn="1" EndLine="10" Image="" Label="">
<ClassOrInterfaceDeclaration Abstract="false" BeginColumn="8" BeginLine="1" EndColumn="1" EndLine="10" Final="false" Image="pmdTestSomeCollection" Interface="false" Label="" Modifiers="1" Native="false" Nested="false" PackagePrivate="false" Private="false" Protected="false" Public="true" Static="false" Strictfp="false" Synchronized="false" Transient="false" Volatile="false">
<ClassOrInterfaceBody BeginColumn="36" BeginLine="1" EndColumn="1" EndLine="10" Image="" Label="">
<ClassOrInterfaceBodyDeclaration AnonymousInnerClass="false" BeginColumn="1" BeginLine="2" EndColumn="49" EndLine="2" EnumChild="false" Image="" Label="">
<FieldDeclaration Abstract="false" Array="false" ArrayDepth="0" BeginColumn="1" BeginLine="2" EndColumn="49" EndLine="2" Final="false" Image="" InterfaceMember="false" Label="" Modifiers="0" Native="false" PackagePrivate="true" Private="false" Protected="false" Public="false" Static="false" Strictfp="false" Synchronized="false" SyntacticallyFinal="false" SyntacticallyPublic="false" SyntacticallyStatic="false" Transient="false" VariableName="sb11" Volatile="false">
<Type Array="false" ArrayDepth="0" BeginColumn="1" BeginLine="2" EndColumn="12" EndLine="2" Image="" Label="" TypeImage="StringBuffer">
<ReferenceType Array="false" ArrayDepth="0" BeginColumn="1" BeginLine="2" EndColumn="12" EndLine="2" Image="" Label="">
<ClassOrInterfaceType BeginColumn="1" BeginLine="2" EndColumn="12" EndLine="2" Image="StringBuffer" Label=""/>
</ReferenceType>
</Type>
<VariableDeclarator BeginColumn="14" BeginLine="2" EndColumn="48" EndLine="2" Image="" Label="">
<VariableDeclaratorId Array="false" ArrayDepth="0" BeginColumn="14" BeginLine="2" EndColumn="17" EndLine="2" ExceptionBlockParameter="false" Image="sb11" Label=""/>
<VariableInitializer BeginColumn="21" BeginLine="2" EndColumn="48" EndLine="2" Image="" Label="">
<Expression BeginColumn="21" BeginLine="2" EndColumn="48" EndLine="2" Image="" Label="">
<PrimaryExpression BeginColumn="21" BeginLine="2" EndColumn="48" EndLine="2" Image="" Label="">
<PrimaryPrefix BeginColumn="21" BeginLine="2" EndColumn="48" EndLine="2" Image="" Label="" SuperModifier="false" ThisModifier="false">
<AllocationExpression BeginColumn="21" BeginLine="2" EndColumn="48" EndLine="2" Image="" Label="">
<ClassOrInterfaceType BeginColumn="25" BeginLine="2" EndColumn="36" EndLine="2" Image="StringBuffer" Label=""/>
<Arguments ArgumentCount="1" BeginColumn="37" BeginLine="2" EndColumn="48" EndLine="2" Image="" Label="">
<ArgumentList BeginColumn="38" BeginLine="2" EndColumn="47" EndLine="2" Image="" Label="">
<Expression BeginColumn="38" BeginLine="2" EndColumn="47" EndLine="2" Image="" Label="">
<PrimaryExpression BeginColumn="38" BeginLine="2" EndColumn="47" EndLine="2" Image="" Label="">
<PrimaryPrefix BeginColumn="38" BeginLine="2" EndColumn="47" EndLine="2" Image="" Label="" SuperModifier="false" ThisModifier="false">
<Literal BeginColumn="38" BeginLine="2" CharLiteral="false" EndColumn="47" EndLine="2" FloatLiteral="false" Image=""abcdeeee"" IntLiteral="false" Label="" SingleCharacterStringLiteral="false" StringLiteral="true"/>
</PrimaryPrefix>
</PrimaryExpression>
</Expression>
</ArgumentList>
</Arguments>
</AllocationExpression>
</PrimaryPrefix>
</PrimaryExpression>
</Expression>
</VariableInitializer>
</VariableDeclarator>
</FieldDeclaration>
</ClassOrInterfaceBodyDeclaration>
<ClassOrInterfaceBodyDeclaration AnonymousInnerClass="false" BeginColumn="3" BeginLine="3" EndColumn="3" EndLine="9" EnumChild="false" Image="" Label="">
<MethodDeclaration Abstract="false" BeginColumn="17" BeginLine="3" EndColumn="3" EndLine="9" Final="false" Image="" InterfaceMember="false" Label="" MethodName="main" Modifiers="17" Native="false" PackagePrivate="false" Private="false" Protected="false" Public="true" Static="true" Strictfp="false" Synchronized="false" SyntacticallyAbstract="false" SyntacticallyPublic="true" Transient="false" Void="true" Volatile="false">
<ResultType BeginColumn="17" BeginLine="3" EndColumn="20" EndLine="3" Image="" Label="" Void="true" returnsArray="false"/>
<MethodDeclarator BeginColumn="22" BeginLine="3" EndColumn="40" EndLine="3" Image="main" Label="" ParameterCount="1">
<FormalParameters BeginColumn="26" BeginLine="3" EndColumn="40" EndLine="3" Image="" Label="" ParameterCount="1">
<FormalParameter Abstract="false" Array="true" ArrayDepth="1" BeginColumn="27" BeginLine="3" EndColumn="39" EndLine="3" Final="false" Image="" Label="" Modifiers="0" Native="false" PackagePrivate="true" Private="false" Protected="false" Public="false" Static="false" Strictfp="false" Synchronized="false" Transient="false" Varargs="false" Volatile="false">
<Type Array="false" ArrayDepth="0" BeginColumn="27" BeginLine="3" EndColumn="32" EndLine="3" Image="" Label="" TypeImage="String">
<ReferenceType Array="false" ArrayDepth="0" BeginColumn="27" BeginLine="3" EndColumn="32" EndLine="3" Image="" Label="">
<ClassOrInterfaceType BeginColumn="27" BeginLine="3" EndColumn="32" EndLine="3" Image="String" Label=""/>
</ReferenceType>
</Type>
<VariableDeclaratorId Array="true" ArrayDepth="1" BeginColumn="34" BeginLine="3" EndColumn="39" EndLine="3" ExceptionBlockParameter="false" Image="args" Label=""/>
</FormalParameter>
</FormalParameters>
</MethodDeclarator>
<Block BeginColumn="42" BeginLine="3" EndColumn="3" EndLine="9" Image="" Label="" containsComment="false">
<BlockStatement Allocation="true" BeginColumn="5" BeginLine="4" EndColumn="49" EndLine="4" Image="" Label="">
<LocalVariableDeclaration Abstract="false" Array="false" ArrayDepth="0" BeginColumn="5" BeginLine="4" EndColumn="48" EndLine="4" Final="false" Image="" Label="" Modifiers="0" Native="false" PackagePrivate="true" Private="false" Protected="false" Public="false" Static="false" Strictfp="false" Synchronized="false" Transient="false" VariableName="sb1" Volatile="false">
<Type Array="false" ArrayDepth="0" BeginColumn="5" BeginLine="4" EndColumn="16" EndLine="4" Image="" Label="" TypeImage="StringBuffer">
<ReferenceType Array="false" ArrayDepth="0" BeginColumn="5" BeginLine="4" EndColumn="16" EndLine="4" Image="" Label="">
<ClassOrInterfaceType BeginColumn="5" BeginLine="4" EndColumn="16" EndLine="4" Image="StringBuffer" Label=""/>
</ReferenceType>
</Type>
<VariableDeclarator BeginColumn="18" BeginLine="4" EndColumn="48" EndLine="4" Image="" Label="">
<VariableDeclaratorId Array="false" ArrayDepth="0" BeginColumn="18" BeginLine="4" EndColumn="20" EndLine="4" ExceptionBlockParameter="false" Image="sb1" Label=""/>
<VariableInitializer BeginColumn="24" BeginLine="4" EndColumn="48" EndLine="4" Image="" Label="">
<Expression BeginColumn="24" BeginLine="4" EndColumn="48" EndLine="4" Image="" Label="">
<PrimaryExpression BeginColumn="24" BeginLine="4" EndColumn="48" EndLine="4" Image="" Label="">
<PrimaryPrefix BeginColumn="24" BeginLine="4" EndColumn="48" EndLine="4" Image="" Label="" SuperModifier="false" ThisModifier="false">
<AllocationExpression BeginColumn="24" BeginLine="4" EndColumn="48" EndLine="4" Image="" Label="">
<ClassOrInterfaceType BeginColumn="28" BeginLine="4" EndColumn="39" EndLine="4" Image="StringBuffer" Label=""/>
<Arguments ArgumentCount="1" BeginColumn="40" BeginLine="4" EndColumn="48" EndLine="4" Image="" Label="">
<ArgumentList BeginColumn="41" BeginLine="4" EndColumn="47" EndLine="4" Image="" Label="">
<Expression BeginColumn="41" BeginLine="4" EndColumn="47" EndLine="4" Image="" Label="">
<PrimaryExpression BeginColumn="41" BeginLine="4" EndColumn="47" EndLine="4" Image="" Label="">
<PrimaryPrefix BeginColumn="41" BeginLine="4" EndColumn="47" EndLine="4" Image="" Label="" SuperModifier="false" ThisModifier="false">
<Literal BeginColumn="41" BeginLine="4" CharLiteral="false" EndColumn="47" EndLine="4" FloatLiteral="false" Image=""abcde"" IntLiteral="false" Label="" SingleCharacterStringLiteral="false" StringLiteral="true"/>
</PrimaryPrefix>
</PrimaryExpression>
</Expression>
</ArgumentList>
</Arguments>
</AllocationExpression>
</PrimaryPrefix>
</PrimaryExpression>
</Expression>
</VariableInitializer>
</VariableDeclarator>
</LocalVariableDeclaration>
</BlockStatement>
<BlockStatement Allocation="false" BeginColumn="5" BeginLine="5" EndColumn="29" EndLine="5" Image="" Label="">
<Statement BeginColumn="5" BeginLine="5" EndColumn="29" EndLine="5" Image="" Label="">
<StatementExpression BeginColumn="5" BeginLine="5" EndColumn="28" EndLine="5" Image="" Label="">
<PrimaryExpression BeginColumn="5" BeginLine="5" EndColumn="28" EndLine="5" Image="" Label="">
<PrimaryPrefix BeginColumn="5" BeginLine="5" EndColumn="14" EndLine="5" Image="" Label="" SuperModifier="false" ThisModifier="false">
<Name BeginColumn="5" BeginLine="5" EndColumn="14" EndLine="5" Image="sb1.append" Label=""/>
</PrimaryPrefix>
<PrimarySuffix ArgumentCount="1" Arguments="true" ArrayDereference="false" BeginColumn="15" BeginLine="5" EndColumn="28" EndLine="5" Image="" Label="">
<Arguments ArgumentCount="1" BeginColumn="15" BeginLine="5" EndColumn="28" EndLine="5" Image="" Label="">
<ArgumentList BeginColumn="16" BeginLine="5" EndColumn="27" EndLine="5" Image="" Label="">
<Expression BeginColumn="16" BeginLine="5" EndColumn="27" EndLine="5" Image="" Label="">
<PrimaryExpression BeginColumn="16" BeginLine="5" EndColumn="27" EndLine="5" Image="" Label="">
<PrimaryPrefix BeginColumn="16" BeginLine="5" EndColumn="27" EndLine="5" Image="" Label="" SuperModifier="false" ThisModifier="false">
<Literal BeginColumn="16" BeginLine="5" CharLiteral="false" EndColumn="27" EndLine="5" FloatLiteral="false" Image=""abcdefghij"" IntLiteral="false" Label="" SingleCharacterStringLiteral="false" StringLiteral="true"/>
</PrimaryPrefix>
</PrimaryExpression>
</Expression>
</ArgumentList>
</Arguments>
</PrimarySuffix>
</PrimaryExpression>
</StatementExpression>
</Statement>
</BlockStatement>
<BlockStatement Allocation="false" BeginColumn="5" BeginLine="6" EndColumn="37" EndLine="6" Image="" Label="">
<LocalVariableDeclaration Abstract="false" Array="false" ArrayDepth="0" BeginColumn="5" BeginLine="6" EndColumn="36" EndLine="6" Final="false" Image="" Label="" Modifiers="0" Native="false" PackagePrivate="true" Private="false" Protected="false" Public="false" Static="false" Strictfp="false" Synchronized="false" Transient="false" VariableName="sb2" Volatile="false">
<Type Array="false" ArrayDepth="0" BeginColumn="5" BeginLine="6" EndColumn="16" EndLine="6" Image="" Label="" TypeImage="StringBuffer">
<ReferenceType Array="false" ArrayDepth="0" BeginColumn="5" BeginLine="6" EndColumn="16" EndLine="6" Image="" Label="">
<ClassOrInterfaceType BeginColumn="5" BeginLine="6" EndColumn="16" EndLine="6" Image="StringBuffer" Label=""/>
</ReferenceType>
</Type>
<VariableDeclarator BeginColumn="18" BeginLine="6" EndColumn="36" EndLine="6" Image="" Label="">
<VariableDeclaratorId Array="false" ArrayDepth="0" BeginColumn="18" BeginLine="6" EndColumn="20" EndLine="6" ExceptionBlockParameter="false" Image="sb2" Label=""/>
<VariableInitializer BeginColumn="24" BeginLine="6" EndColumn="36" EndLine="6" Image="" Label="">
<Expression BeginColumn="24" BeginLine="6" EndColumn="36" EndLine="6" Image="" Label="">
<PrimaryExpression BeginColumn="24" BeginLine="6" EndColumn="36" EndLine="6" Image="" Label="">
<PrimaryPrefix BeginColumn="24" BeginLine="6" EndColumn="34" EndLine="6" Image="" Label="" SuperModifier="false" ThisModifier="false">
<Name BeginColumn="24" BeginLine="6" EndColumn="34" EndLine="6" Image="sb1.reverse" Label=""/>
</PrimaryPrefix>
<PrimarySuffix ArgumentCount="0" Arguments="true" ArrayDereference="false" BeginColumn="35" BeginLine="6" EndColumn="36" EndLine="6" Image="" Label="">
<Arguments ArgumentCount="0" BeginColumn="35" BeginLine="6" EndColumn="36" EndLine="6" Image="" Label=""/>
</PrimarySuffix>
</PrimaryExpression>
</Expression>
</VariableInitializer>
</VariableDeclarator>
</LocalVariableDeclaration>
</BlockStatement>
<BlockStatement Allocation="false" BeginColumn="5" BeginLine="7" EndColumn="28" EndLine="7" Image="" Label="">
<Statement BeginColumn="5" BeginLine="7" EndColumn="28" EndLine="7" Image="" Label="">
<StatementExpression BeginColumn="5" BeginLine="7" EndColumn="27" EndLine="7" Image="" Label="">
<PrimaryExpression BeginColumn="5" BeginLine="7" EndColumn="27" EndLine="7" Image="" Label="">
<PrimaryPrefix BeginColumn="5" BeginLine="7" EndColumn="22" EndLine="7" Image="" Label="" SuperModifier="false" ThisModifier="false">
<Name BeginColumn="5" BeginLine="7" EndColumn="22" EndLine="7" Image="System.out.println" Label=""/>
</PrimaryPrefix>
<PrimarySuffix ArgumentCount="1" Arguments="true" ArrayDereference="false" BeginColumn="23" BeginLine="7" EndColumn="27" EndLine="7" Image="" Label="">
<Arguments ArgumentCount="1" BeginColumn="23" BeginLine="7" EndColumn="27" EndLine="7" Image="" Label="">
<ArgumentList BeginColumn="24" BeginLine="7" EndColumn="26" EndLine="7" Image="" Label="">
<Expression BeginColumn="24" BeginLine="7" EndColumn="26" EndLine="7" Image="" Label="">
<PrimaryExpression BeginColumn="24" BeginLine="7" EndColumn="26" EndLine="7" Image="" Label="">
<PrimaryPrefix BeginColumn="24" BeginLine="7" EndColumn="26" EndLine="7" Image="" Label="" SuperModifier="false" ThisModifier="false">
<Name BeginColumn="24" BeginLine="7" EndColumn="26" EndLine="7" Image="sb1" Label=""/>
</PrimaryPrefix>
</PrimaryExpression>
</Expression>
</ArgumentList>
</Arguments>
</PrimarySuffix>
</PrimaryExpression>
</StatementExpression>
</Statement>
</BlockStatement>
<BlockStatement Allocation="false" BeginColumn="5" BeginLine="8" EndColumn="28" EndLine="8" Image="" Label="">
<Statement BeginColumn="5" BeginLine="8" EndColumn="28" EndLine="8" Image="" Label="">
<StatementExpression BeginColumn="5" BeginLine="8" EndColumn="27" EndLine="8" Image="" Label="">
<PrimaryExpression BeginColumn="5" BeginLine="8" EndColumn="27" EndLine="8" Image="" Label="">
<PrimaryPrefix BeginColumn="5" BeginLine="8" EndColumn="22" EndLine="8" Image="" Label="" SuperModifier="false" ThisModifier="false">
<Name BeginColumn="5" BeginLine="8" EndColumn="22" EndLine="8" Image="System.out.println" Label=""/>
</PrimaryPrefix>
<PrimarySuffix ArgumentCount="1" Arguments="true" ArrayDereference="false" BeginColumn="23" BeginLine="8" EndColumn="27" EndLine="8" Image="" Label="">
<Arguments ArgumentCount="1" BeginColumn="23" BeginLine="8" EndColumn="27" EndLine="8" Image="" Label="">
<ArgumentList BeginColumn="24" BeginLine="8" EndColumn="26" EndLine="8" Image="" Label="">
<Expression BeginColumn="24" BeginLine="8" EndColumn="26" EndLine="8" Image="" Label="">
<PrimaryExpression BeginColumn="24" BeginLine="8" EndColumn="26" EndLine="8" Image="" Label="">
<PrimaryPrefix BeginColumn="24" BeginLine="8" EndColumn="26" EndLine="8" Image="" Label="" SuperModifier="false" ThisModifier="false">
<Name BeginColumn="24" BeginLine="8" EndColumn="26" EndLine="8" Image="sb2" Label=""/>
</PrimaryPrefix>
</PrimaryExpression>
</Expression>
</ArgumentList>
</Arguments>
</PrimarySuffix>
</PrimaryExpression>
</StatementExpression>
</Statement>
</BlockStatement>
</Block>
</MethodDeclaration>
</ClassOrInterfaceBodyDeclaration>
</ClassOrInterfaceBody>
</ClassOrInterfaceDeclaration>
</TypeDeclaration>
</CompilationUnit>
I don't think its possible, it workes for one local variable declared in any method and the first parameter in any class. The big problem here is that once you are inside a predicate and you specify a path which will return multiple nodes, the predicate is only applied to the first node.
For example in your code below the //LocalVariableDeclaration/.../VariableDeclaratorId should compare against all local variables but it only matches against the first LocalVariable which matches the String buffer predicate. There is a for construct in XPath 2.0 which supports these kinds of queries but it is not supported by PMD as yet.
... and contains(#Image,
//LocalVariableDeclaration[descendant::ClassOrInterfaceType[#Image='StringBuffer']]
/VariableDeclarator/VariableDeclaratorId/#Image)]
I am trying to create an installer using WiX which doesn't show the license agreement at the start. But I get the error as below.
This is the full Product.wxs file I have at the moment. It compiles and builds OK. Why am I getting an error like this? Is my Fragment section in the right place? I have removed the Publish elements pertaining to license and modified the welcome dialog's next button to show the install directory dialog instead of license agreement. This is as mentioned in the help chm file. What am I missing then?
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="077765d1-236d-4299-b751-f921828f2ac8"
Name="Wix Setup Example"
Language="1033"
Version="1.0.0.0"
Manufacturer="NBL" UpgradeCode="1b0f72a7-8e17-4897-9f96-66509cc39573">
<Package InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" >
<Directory Id="INSTALLLOCATION" Name="My Application Folder">
<Component Id="ProductComponent" Guid="MY-GUID-HERE">
<File Id="WindowsFormsApp.exe"
Source="../WindowsFormsApp/bin/Debug/WindowsFormsApp.exe">
</File>
</Component>
</Directory>
</Directory>
</Directory>
<Feature Id="ProductFeature" Title="WixSetupProject" Level="1">
<ComponentRef Id="ProductComponent" />
</Feature>
<UI Id="WixUI_Advanced">
<TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
<TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
<TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />
<Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
<Property Id="WixUI_Mode" Value="Advanced" />
<DialogRef Id="BrowseDlg" />
<DialogRef Id="DiskCostDlg" />
<DialogRef Id="ErrorDlg" />
<DialogRef Id="FatalError" />
<DialogRef Id="FilesInUse" />
<DialogRef Id="MsiRMFilesInUse" />
<DialogRef Id="PrepareDlg" />
<DialogRef Id="ProgressDlg" />
<DialogRef Id="ResumeDlg" />
<DialogRef Id="UserExit" />
<Publish Dialog="BrowseDlg" Control="OK" Event="DoAction" Value="WixUIValidatePath" Order="3">1</Publish>
<Publish Dialog="BrowseDlg" Control="OK" Event="SpawnDialog" Value="InvalidDirDlg" Order="4"><![CDATA[WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg" Order="1">NOT Installed</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="1">Installed AND PATCH</Publish>
<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="WixUIValidatePath" Order="2">NOT WIXUI_DONTVALIDATEPATH</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="SpawnDialog" Value="InvalidDirDlg" Order="3"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="4">WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"</Publish>
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="InstallDirDlg" Order="1">NOT Installed</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2">Installed AND NOT PATCH</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2">Installed AND PATCH</Publish>
<Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>
<Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
<Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
<Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>
<Property Id="ARPNOMODIFY" Value="1" />
</UI>
<UIRef Id="WixUI_Common" />
</Product>
<Fragment>
<Property Id="ApplicationFolderName" Value="My Application Folder" />
<Property Id="WixAppFolder" Value="WixPerMachineFolder" />
<WixVariable Id="WixUISupportPerUser" Value="1" Overridable="yes" />
<WixVariable Id="WixUISupportPerMachine" Value="1" Overridable="yes" />
<PropertyRef Id="ApplicationFolderName" />
</Fragment>
</Wix>
The edited version of the WiX file that gives no error. This version however skips the install feature and browse for the file dialog:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="077765d1-236d-4299-b751-f921828f2ac8"
Name="Wix Setup Example"
Language="1033"
Version="1.0.0.0"
Manufacturer="NBL" UpgradeCode="1b0f72a7-8e17-4897-9f96-66599gg39573">
<Package InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLLOCATION" Name="My Application Folder">
<Component Id="ProductComponent" Guid="17e13748-8d44-47f6-b020-66d29f8a84fe">
<File Id="WindowsFormsApp.exe"
Source="../WindowsFormsApp/bin/Debug/WindowsFormsApp.exe">
</File>
</Component>
</Directory>
</Directory>
</Directory>
<Feature Id="ProductFeature" Title="WixSetupProject" Level="1">
<ComponentRef Id="ProductComponent" />
</Feature>
<UI Id="WixUI_Advanced">
<TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
<TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
<TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />
<Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
<Property Id="WixUI_Mode" Value="Advanced" />
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLLOCATION" />
<DialogRef Id="BrowseDlg" />
<DialogRef Id="DiskCostDlg" />
<DialogRef Id="ErrorDlg" />
<DialogRef Id="FatalError" />
<DialogRef Id="FilesInUse" />
<DialogRef Id="MsiRMFilesInUse" />
<DialogRef Id="PrepareDlg" />
<DialogRef Id="ProgressDlg" />
<DialogRef Id="ResumeDlg" />
<DialogRef Id="UserExit" />
<Publish Dialog="BrowseDlg" Control="OK" Event="DoAction" Value="WixUIValidatePath" Order="3">1</Publish>
<Publish Dialog="BrowseDlg" Control="OK" Event="SpawnDialog" Value="InvalidDirDlg" Order="4"><![CDATA[WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="BrowseDlg" Order="1">1</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="1">1</Publish>
<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="BrowseDlg">1</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="WixUIValidatePath" Order="2">NOT WIXUI_DONTVALIDATEPATH</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="SpawnDialog" Value="InvalidDirDlg" Order="3"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="4">WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"</Publish>
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="1">NOT Installed</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2">Installed AND NOT PATCH</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2">Installed AND PATCH</Publish>
<Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>
<Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
<Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
<Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>
<Property Id="ARPNOMODIFY" Value="1" />
</UI>
<UIRef Id="WixUI_Common" />
</Product>
<Fragment>
<Property Id="ApplicationFolderName" Value="My Application Folder" />
<Property Id="WixAppFolder" Value="WixPerMachineFolder" />
<WixVariable Id="WixUISupportPerUser" Value="1" Overridable="yes" />
<WixVariable Id="WixUISupportPerMachine" Value="1" Overridable="yes" />
<PropertyRef Id="ApplicationFolderName" />
<UI >
<Dialog Id="CustomBrowseDlg" Width="370" Height="270" Title="!(loc.BrowseDlg_Title)">
<Control Id="PathEdit" Type="PathEdit" X="25" Y="202" Width="320" Height="18" Property="_BrowseProperty" Indirect="yes" />
<Control Id="OK" Type="PushButton" X="240" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUIOK)">
<Publish Event="SetTargetPath" Value="[_BrowseProperty]">1</Publish>
<Publish Event="EndDialog" Value="Return">1</Publish>
</Control>
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
<Publish Event="Reset" Value="0">1</Publish>
<Publish Event="EndDialog" Value="Return">1</Publish>
</Control>
<Control Id="ComboLabel" Type="Text" X="25" Y="58" Width="44" Height="10" TabSkip="no" Text="!(loc.BrowseDlgComboLabel)" />
<Control Id="DirectoryCombo" Type="DirectoryCombo" X="70" Y="55" Width="220" Height="80" Property="_BrowseProperty" Indirect="yes" Fixed="yes" Remote="yes">
<Subscribe Event="IgnoreChange" Attribute="IgnoreChange" />
</Control>
<Control Id="WixUI_Bmp_Up" Type="PushButton" X="298" Y="55" Width="19" Height="19" ToolTip="!(loc.BrowseDlgWixUI_Bmp_UpTooltip)" Icon="yes" FixedSize="yes" IconSize="16" Text="!(loc.BrowseDlgWixUI_Bmp_Up)">
<Publish Event="DirectoryListUp" Value="0">1</Publish>
</Control>
<Control Id="NewFolder" Type="PushButton" X="325" Y="55" Width="19" Height="19" ToolTip="!(loc.BrowseDlgNewFolderTooltip)" Icon="yes" FixedSize="yes" IconSize="16" Text="!(loc.BrowseDlgNewFolder)">
<Publish Event="DirectoryListNew" Value="0">1</Publish>
</Control>
<Control Id="DirectoryList" Type="DirectoryList" X="25" Y="83" Width="320" Height="98" Property="_BrowseProperty" Sunken="yes" Indirect="yes" TabSkip="no" />
<Control Id="PathLabel" Type="Text" X="25" Y="190" Width="320" Height="10" TabSkip="no" Text="!(loc.BrowseDlgPathLabel)" />
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.BrowseDlgBannerBitmap)" />
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="!(loc.BrowseDlgDescription)" />
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="!(loc.BrowseDlgTitle)" />
</Dialog>
</UI>
</Fragment>
</Wix>
Removing that gets the following error in the MSI logs:
DEBUG: Error 2819: Control Folder on dialog InstallDirDlg needs a property linked to it
Basically this means that the "browse for folder" control isn't linked up to an actual property value. You've used the value INSTALLLOCATION for the application folder - which in turn means you'll need to add the following value to link the dialog:
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLLOCATION" />
Good luck!
My experience is: you should add Property attribute in Control tag. Like:
<Control Id="NameEdit" Type="Edit"
X="45" Y="85" Width="220" Height="18"
Property="USERNAME" Text="{80}" />
Error code 2819 means "Control [3] on dialog [2] needs a property linked to it" (taken from Windows Installer Error Messages). If you extract the MSI traces (add /l*v to the command line) you'll be able to see what [3] and [2] stand for, and continue debugging from there.