Windows phone toolkit ListPicker only allowing 5 elements - xaml

I have a simple working example:
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<toolkit:ListPicker>
<toolkit:ListPickerItem Content="FIRST" />
<toolkit:ListPickerItem Content="SECOND" />
<toolkit:ListPickerItem Content="THIRD" />
<toolkit:ListPickerItem Content="FOURTH" />
<toolkit:ListPickerItem Content="FIFTH" />
<toolkit:ListPickerItem Content="SIXTH" />
</toolkit:ListPicker>
</Grid>
create a new windows phone 8 app, install the windows phone toolkit nuget package, then add only the listpicker as shown above. It will blow. But, if you delete the sixth ListPickerItem, then it works.
Has anyone else gotten the listpicker to work? Do I need to add the items in code to get this to work?

by default list picker only allow 5 elements to show on the same view if it is more than that it will show it will take a full single view to show the elements and for that you have to add the elements from code behind. or you can change ItemCountThreshold.

The answer from souvickcse is not working anymore, because ItemCountThreshold is read-only now. Here's a "hack" which will work. Replace "ListPicker" with the Name you have given to your listpicker.
ListPicker.SetValue(Microsoft.Phone.Controls.ListPicker.ItemCountThresholdProperty, 100);

Related

Is there any better way to give conditional styling in uwp?

I have tried to give conditional styling using converter in style.setter as below,
<Style TargetType="DataGrid">
<Setter Property="Background" Value="{Binding Converter={StaticResource cc}}" />
</Style>
and came to know that there is no support provided for using converter in UWP. So please anyone suggest me better way to provide conditional styling in UWP using converter in style.setter
No, we don't have Trigger support in UWP.
To keep the as much as light the triggers from UWP and Windows phone 8
are removed by msft. We could achieve those using Interactivity core. Blend(IDE) has great support to create trigger in these technologies.
Blend allows to define a behavior for the application Here.
We could define
DataTrigger Use the DataTrigger trigger to invoke an action based on the value of a data-bound property
EventTrigger Use the EventTrigger trigger to invoke an action based on an event such as a mouse click, a page loading, or another interaction.
KeyTrigger Use the KeyTrigger trigger to invoke an action when a combination of keys is pressed on the keyboard.
Note:- This are trigger available for windows phone,make sure UWP have this trigger in the blend SDK
A workaround is to use DataTriggerBehavior with a ChangePropertyAction to accomplish this.
xmlns:ec="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" x:Class="XXX_XXXX"
This works for me
<DataGrid x:Name="MyGrid"
Stretch="None"
HorizontalAlignment="Stretch"
VerticalAlignment="Top">
<interactivity:Interaction.Triggers>
<ec:DataTrigger Binding="{Binding IsBackgroundBlue}" Value="True">
<ec:ChangePropertyAction TargetObject="{Binding ElementName=MyGrid}" PropertyName="Background" Value="Blue" />
</ec:DataTrigger>
<!-- You could add your conditions here /> -->
</interactivity:Interaction.Triggers>
</DataGrid>
Pls mind this may not be correct syntax i dont have IDE now
Similar answer in https://stackoverflow.com/a/31933556/1876572
Msdn reference of triggers using visual state manager

How to reuse XAML code blocks without binding?

I have this XAML code block:
<StackPanel Orientation="Horizontal">
<TextBlock Text="Hello " />
<TextBlock Text="World" />
</StackPanel>
I would like to define this block (for example in /Common/CustomStyles.xaml) to include it on different XAML pages. How does it work?
I do not need a DataTemplate or something similar because the text is static.
You could put it in a user control and re-use it that way. If it's just the text you are interested in then you could use a resource file - this would update the textbox on any screen as long as it had the right uid.

Windows 8 bottom app bar

I've been trying to get an App bar implemented in a WinRT metro app (C# / XAML), but don't know where to begin. I've tried using the <ApplicationBar/> tag and I get a Type not found error.
There's no help online, could someone update this post with the answer so that it'll serve as a reference to other programmers as well?
There's only a JavaScript sample which isn't of much help.
This should work:
<AppBar
VerticalAlignment="Bottom">
<Button
AutomationProperties.Name="Play"
Style="{StaticResource PlayAppBarButtonStyle}"
Command="{Binding PlayCommand}" />
</AppBar>
– you would put that in the layout root grid of your page.
*EDIT
Note: According to documentation - you should put it in Page.BottomAppBar property, although at least in Windows 8 Consumer Preview - it works fine when used in any Grid, which is convenient if your UI isn't tightly coupled to a Page control.
*EDIT 2, response from MSFT:
The recommended approach is to use the Page.BottomAppBar/TopAppBar properties.
There are known hit-testing issues in the Consumer Preview if AppBars are added without using these properties
The AppBars do not use the proper animations if they are added without using these properties
If AppBars are added as children of arbitrary elements then it's easier for multiple controls to attempt to create/modify AppBars, resulting in an inconsistent user experience
*EDIT 3
The CustomAppBar in WinRT XAML Toolkit can be used anywhere, animates based on Vertical/Horizontal-Alignment, can have other content overlaid on top of it and also has a CanOpen property that allows to block it from opening.
<Page.TopAppBar>
<AppBar>
<TextBlock x:Name="TextBlock1" Text="Sample Text" Margin="0,0,0,0" Height="Auto" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</AppBar>
</Page.TopAppBar>

Sitecore custom dialog application remains empty

So I've created a small custom dialog application for sitecore that is called through a ribbon button which triggers a command which in turn triggers my custom control.
My command (which works in triggering the open dialog trigger):
var uri = UIUtil.GetUri("control:LanguageCopyModule");
var id = context.Items[0].ID.ToString();
var la = context.Items[0].Language;
var url = string.Format("{0}&id={1}&la={2}", uri, id, la.Name);
SheerResponse.ShowModalDialog(url);
The URL it generates in a popup window:
http://mydomain/sitecore/shell/default.aspx?xmlcontrol=LanguageCopyModule&id={E67AD356-3999-4D4C-ACE4-C570EFD1FBE0}&la=en
Untill this point it all works prefectly, but now when it opens my xml control window it just stays empty.
This is the code behind the xml:
<control xmlns:def="Definition" xmlns="http://schemas.sitecore.net/Visual-Studio-Intellisense">
<LanguageCopyModule>
<FormDialog Icon="Applications/16x16/paste.png" Header="Language Copy Module" Text="Copy field values between different languages." OKButton="Copy" CancelButton="Cancel">
<CodeBeside Type="MyAssembly.Modules.LanguageCopyModule.LanguageCopyModule,MyAssembly.Modules"/>
<GridPanel Columns="2">
<GridPanel.ColumnStyles>
<Column Width="70%" />
<Column Width="30%" />
</GridPanel.ColumnStyles>
<GridPanel.RowStyles>
<Row Height="100%" />
</GridPanel.RowStyles>
<!-- Fields -->
<FlowPanel>
<Border BorderThickness="1" BorderBrush="black">
<Text>Text</Text>
</Border>
</FlowPanel>
<!-- Languages -->
<FlowPanel>
<Border BorderThickness="1" BorderBrush="black">
<Button>Button</Button>
</Border>
</FlowPanel>
</GridPanel>
</FormDialog>
</LanguageCopyModule>
</control>
Any ideas as to why it remains empty? There's little documentation to be found and it could be I just missed something.
Thanks for any assistance!
This is regulated by the <controlSources> element in web.config. You can either put your XML control to any of the folders mentioned there, or add another control source. Note that there's a special "override" folder foreseen for such purpose. If you still need to add your own control source, remember that from Sitecore 6.0 it can be done in a pluggable configs (there's official Sitecore doc on this plus several blog posts out there).
I have found the issue: the .xml file NEEDS to be somewhere under /sitecore/shell in your filesystem.

Silverlight - displaying graphical resources within a button

Has anyone solved this: displaying graphical resources within a button
create a resource, for instance a rectangle
<UserControl.Resources>
<Rectangle x:Key="myRectangle" Fill="Red" Height="100" Width="100"/>
</UserControl.Resources>
then set the content of the button to the resource
<Button Content="{StaticResource myRectangle}"/>
when you build inside blend 4 RC you get the error "Value does not fall within the expected range."
Visual studio does not show this error.
When you run the site the button doesn't show any content.
This technique works in WPF without problems.
Anyone got any ideas?
This can be done by directly setting the shape as the button's content. For eg:
<Button Height="120" Width="120">
<Rectangle Fill="Red" Height="100" Width="100"/>
</Button>
FrameworkElement.Resources are generally used for storing nonvisual elements, brushes, etc. For your case (I think) you'll need to store your xaml as a data template, again not sure if this works with Buttons, it is used for things like ListBoxes. See here:
resources description on msdn. The link further contains pointers to information for Data Templates etc.