combo box selection property change - wix

I am writing an installer for an application. As part of that I am required to get the country name the user selects. If the user selects United States, I want the value US in my program, i.e. 2 letter code.
Currently I implemented the combo box like this:
<Control Id="CountryList" Type="ComboBox" Sorted="yes" ComboList="yes" Property="COUNTRY" X="30" Y="118" Width="150" Height="15">
<ComboBox Property="COUNTRY">
<ListItem Value="United States" />
<ListItem Value="India" />
<ListItem Value="Australia" />
<ListItem Value="United Kingdom" />
</ComboBox>
</Control>
Can anyone please suggest me how to change the property COUNTRY to US or IN or UK etc. I mean 2 letter code.
Also I have to add all possible countries. Any better way to accomplish this?
Related to this, I want the first combobox to list all the countries. The second combobox can then show the states that belong to the country. :)

Use the Text attribute for a visible text, and Value attribute for the value to be put into the ComboBox property when the item is selected:
<Control Id="CountryList" Type="ComboBox" Sorted="yes" ComboList="yes" Property="COUNTRY" X="30" Y="118" Width="150" Height="15">
<ComboBox Property="COUNTRY">
<ListItem Text="United States" Value="US" />
<ListItem Text="United Kingdom" Value="UK" />
...
</ComboBox>
</Control>
As for your other questions:
Also I have to add all possible countries. Any better way to
accomplish this?
You can take inspiration from this thread and add a build-time step to generate an XML fragment of <ListItem> elements.
The second combobox can then show the states that belong to the
country.
Note that there's no way to catch the event when a selected item is changed in a combobox. That's a well-known limitation of the MSI UI. You can try to achieve what you want with the workaround I call "twin-dialogs". See this thread for more information.

Related

How can I add a Datagrid reflecting currect state of ReferenceArrayInput to a react-admin edit form?

I'm writing a user management using react-admin and try to make adding users to groups easier, i.e. by adding groups from a user's edit page using auto-complete. Starting with an example, I've got some success using the following:
<ReferenceArrayInput
label="Group"
source="groups"
reference="groups"
>
<AutocompleteArrayInput
{...props}
resettable={true}
allowEmpty={true}
optionText="name"
fullWidth
/>
</ReferenceArrayInput>
However, this method uses Chip component to display selected items inline. I would like to use a Datagrid instead. I know from the source code that I cannot override the display part of an auto-complete (yet?), so I thought I could resort to hiding Chips via CSS, but I would still need a way to display a Datagrid with current selection. So I tried this (it's wrapped in FormWithRedirect, hence formProps):
<ReferenceArrayField
{...formProps}
label="Group"
source="groups"
reference="groups"
>
<Datagrid>
<TextField source="name" />
</Datagrid>
</ReferenceArrayField>
<ReferenceArrayInput
{...formProps}
label="Group"
source="groups"
reference="groups"
>
<AutocompleteArrayInput
resettable={true}
allowEmpty={true}
optionText="name"
fullWidth
/>
</ReferenceArrayInput>
This works almost exactly as I want it, a Datagrid is displayed and it shows the right data for the selection, however, it's not updated when selected items on AutocompleteArrayInput change. How ever I tried (been through probably all the hooks and contexts), I could not make it work.
Is this possible? How can I make Datagrid update when selection changes on AutocompleteArrayInput?

Why CommandBarFlyout showing only eleven buttons maximum?

I need to create a CommandBarFlyout with many buttons.
My XAML code:
<StackPanel>
<Button Height="40" Width="40">
<Image Source="/Assets/StoreLogo.png"/>
<Button.Flyout>
<CommandBarFlyout>
<AppBarToggleButton>
<AppBarToggleButton.Icon>
<BitmapIcon UriSource="/Assets/StoreLogo.png"/>
</AppBarToggleButton.Icon>
</AppBarToggleButton>
</CommandBarFlyout>
</Button.Flyout>
</Button>
</StackPanel>
If I copy-paste twelve buttons in CommandBarFlyout - only first eleven are showing.
If I add more buttons - still first eleven shown.
From this document about Commandbarflyout, it mentions:
Unlike CommandBar, primary commands do not automatically overflow to
the secondary commands and might be truncated.
So the reason why only 11 buttons are displayed should be that the actual contents have overflowed the scope of the primary command and were truncated.
If you still want to continue to use CommandBarFlyout, you can also add commands to the SecondaryCommands collection. Or as the document said, to use CommandBar or Flyout.

UWP - Pivot IsTabStop not working as expected

I have a pivot that I am trying to keep from gaining focus when the user hits the tab key. I immediately tried to set IsTabStop to false. However this wasn't keeping a user from tabbing into the pivot. So I tried testing IsTabStop on two buttons and the behavior was exactly what I expected from the pivot.
Here is my xaml:
<Pivot IsTabStop="False">
<PivotItem Header="Test">
<StackPanel Spacing="10">
<Button Content="Button 1" IsTabStop="True"/>
<Button Content="Button 2" IsTabStop="False"/>
</StackPanel>
</PivotItem>
</Pivot>
Am I missing something here or is there a way around this?
Setting tab index to -1 only makes it first, try something like 1001.. In here they explain the issue you may be having but for RichTextBlock, there are various attributes available for it to set.. https://learn.microsoft.com/en-us/windows/uwp/design/accessibility/keyboard-accessibility
So what i ended up doing is overriding the default style on the pivot. I changed the "HeaderClipper" in the style to have IsTabStop="False", this fixed my problem.
The documentation for the default pivot style can be found at https://msdn.microsoft.com/en-us/library/windows/apps/mt299144.aspx

Jasper Report How to print ReportElement on next page when it doesn't fit on the same page?

In my code I have large amount of data that is generated to a jasper report inside a subreport that's larger than one page.
When I print it an unwanted page break happens. One element is sometimes printed on the next page when it doesn't fit on the same page.
what I want to happen:
what happens instead:
here's my code:
<group name="ExampleGroup">
<groupExpression><![CDATA[null]]></groupExpression>
<groupHeader>
<band height="17" splitType="Stretch">
<subreport isUsingCache="true">
<reportElement key="subreport-1" positionType="Float" x="0" y="0" width="594" height="16" uuid="some uuid"/>
<parametersMapExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}]]></parametersMapExpression>
<dataSourceExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}.get("DataSource")]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}.get("Data")]]></subreportExpression>
</subreport>
</band>
</groupHeader>
<groupFooter>
<band splitType="Stretch"/>
</groupFooter>
</group>
I already tried to solve the problem by adding parameters, e.g. splitType="Prevent" or keepTogether="true" but both caused an empty page to happen. The parameters I found are only useful when the band should be printed on the same page. But in my case the generated reportElements shouldn't be splitted up. It's not about the group or the band! Because its content is anyway larger than one page. I didn't found anything about that topic.
Probably it would be helpful adding an expression like Group Expression? But I don't know what to add here to say that the row should be printed on the next page when there's not enough space left.
How could I solve that? I'm thankful for any suggestion.
I solved it by adding splitType="Prevent" to the band inside the detail that is called in the subreport.

How to data bind based on emptiness of a collection?

I want to make a TextBlock visible only when a collection is empty. I have a ListView that is data-bound to the collection already and that's simple. I just want to display something else when the ListView is otherwise empty.
I wrote an IValueConverter that would take the collection, or count, or whatever I need, and return a Visibility appropriately. The XAML looks like this:
<TextBlock Visibility="{Binding Count, ElementName=ContactsList, Converter={StaticResource visibilityWhenEmpty}}"
Text="No contacts yet. Add one using the AppBar below." />
The trouble is that binding just the collection itself only calls my value converter once, when it's empty, and not again when the contents of the collection changes (kinda makes sense). And when, as shown above, I try binding against the collection's Count property, it doesn't call my value converter at all.
Any ideas?
I have faced the same issue. I applied a tricky solution. It might work for you as well. Taks a temporary combo box and bind the collection with that.
<ComboBox x:Name="TempComboBox"
ItemsSource="{Binding DataContext.ContactsList,
RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}" >
<ComboBox.Template>
<ControlTemplate>
<!--Add file button..-->
<TextBlock Content="Your text..."
>
<TextBlock.Visibility>
<Binding Path="Items.Count"
RelativeSource="{RelativeSource Mode=FindAncestor,AncestorType=ComboBox}"
Converter="{StaticResource visibilityWhenEmpty}">
</Binding>
</TextBlock.Visibility>
</TextBlock>
</ControlTemplate>
</ComboBox.Template>
</ComboBox>
You could use notifyPropertyChanged for Count, or implement using BindableBase.