French/Portuguese Numero character not rendered in XAML properly - windows-phone-8

I need to display the french and Portuguese Numero character (n.º) in XAML page.
But the underscore under the symbol o is missing while rendering into the XAML page.
Code: <TextBlock FontSize="20" Foreground="Black" Text="Bay n.º"/>
Output: https://i.stack.imgur.com/26Eq9.png
please anyone help me to sort this issue.
Thanks.

Try this:
<TextBlock FontSize="20" Foreground="Black">
<Run Text="Bay n."></Run>
<Run Text="º" TextDecorations="Underline"></Run>
</TextBlock>
You need to underline the character that you want to display, in XAML there are certain combinations that you can only do them with the Run or by code.
Or you can try something like this:
<TextBlock FontSize="20" Foreground="Black" Text="Bay n.№"/>
However, I strongly suggest the first option.
More examples:
https://raviranjankr.wordpress.com/2014/02/27/how-to-format-texts-of-textblock-using-xaml-in-windows-phone/
In this example they do it with C# code, you can try it as a possible alternative.
https://social.msdn.microsoft.com/Forums/en-US/915740e9-a693-40b9-96a4-07d2784d3b53/textblock-underline-in-winrt?forum=winappswithcsharp

Related

Items being reordered in LongListSelector

In my WP8 app, I'm using LongListSelector to display data items. Grouping works, jump list works.
I have the usual master/detail scenario here - click on item in the list, new page shows up with more information.
The problem is with navigating back to the page with LongListSelector. The list is basically messed up - items are randomly reordered, even between groups. Clicking on an item works properly - ShowItemInfo receives view model for the item the user clicked on.
Previously I was using ListBox, which too suffered from this issue. But I could disable virtualization by using default StackPanel as items panel. I don't know how to disable virtualization on LongListSelector (I don't want to, but the bug is horrible).
View model is simple. I'm using Caliburn.Micro, its conventions and BindableCollection for list of groups. I populate the list just once with AddRange method.
When the page is navigated back to, I'm not doing anything - and I even can't since I use MVVM and Caliburn.Micro. The items are loaded into list in OnInitialize callback, which is invoked only once during lifetime of view model.
The XAML for view is this:
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.Resources>
<phone:JumpListItemBackgroundConverter x:Key="BackgroundConverter"/>
<phone:JumpListItemForegroundConverter x:Key="ForegroundConverter"/>
<Style x:Key="ListJumpListStyle" TargetType="phone:LongListSelector">
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<Border Background="{Binding Converter={StaticResource BackgroundConverter}}"
HorizontalAlignment="Stretch">
<TextBlock Text="{Binding GroupTitle}"
Foreground="{Binding Converter={StaticResource ForegroundConverter}}" />
</Border>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<phone:LongListSelector x:Name="Items" LayoutMode="List" IsGroupingEnabled="True"
JumpListStyle="{StaticResource ListJumpListStyle}">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<Grid cal:Bind.Model="{Binding}"
cal:Message.Attach="[Event Tap] = [ShowItemInfo($dataContext)]"
Background="Transparent">
<TextBlock x:Name="ItemText" Style="{StaticResource PhoneTextTitle2Style}" />
</Grid>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
<phone:LongListSelector.GroupHeaderTemplate>
<DataTemplate>
<Border>
<TextBlock Text="{Binding GroupTitle}" />
</Border>
</DataTemplate>
</phone:LongListSelector.GroupHeaderTemplate>
</phone:LongListSelector>
</Grid>
I've narrowed down the issue to the data template, more specifically the attached property Bind.Model, which allows Caliburn.Micro to bind view model to view:
<DataTemplate>
<Grid cal:Bind.Model="{Binding}"
cal:Message.Attach="[Event Tap] = [ShowItemInfo($dataContext)]"
Background="Transparent">
<TextBlock x:Name="ItemText" Style="{StaticResource PhoneTextTitle2Style}" />
</Grid>
</DataTemplate>
When this view is changed to use explicit bindings instead conventions (and Bind.Model attached property is removed), LongListSelector works like a charm.
I believe there has to be a bug within Caliburn.Micro, which causes this issue. Initially, I thought the bug was in the 1.5.2 version, which I'm using (unfortunately I have to), and that it was fixed in new 2.x versions. However, that is not true, the bug is still manifesting in latest stable version 2.0.2.
I was using this technique in WPF without any problems. I've also tried running the app in emulators for WP8.0 and WP8.1, but the behavior is the same.
If anybody finds out, what causes this bug (or new version of Caliburn.Micro fixes it), feel free to edit answer or post a comment. I would be happy to use conventions in data templates again.
My mistake: for data templates, Bind.ModelWithoutContext should be used. Even documentation explicitly says so:
Bind.ModelWithoutContext - View-First - Set’s the Action.Target to the specified instance. Applies conventions to the view. (Use inside
of DataTemplate.)
With Bind.ModelWithoutContext LongListSelector works properly as it should (with conventions in item template).

ListViewItems become blank when enabled NavigationCache and IncrementalUpdateBehavior

Here is my code:
<ListView ItemsSource="{Binding Items}" IsItemClickEnabled="True" ItemClick="ItemView_ItemClick" ContinuumNavigationTransitionInfo.ExitElementContainer="True">
<ListView.ItemTemplate>
<DataTemplate>
<Border BorderBrush="{StaticResource ButtonBorderThemeBrush}" BorderThickness="0,0,0,3">
<StackPanel Margin="0,0,0,9.5">
<TextBlock
Text="{Binding Title}"
TextWrapping="Wrap"
Pivot.SlideInAnimationGroup="1"
CommonNavigationTransitionInfo.IsStaggerElement="True"
Style="{ThemeResource ListViewItemTextBlockStyle}"
Margin="0,0,19,0">
<interactivity:Interaction.Behaviors>
<core:IncrementalUpdateBehavior Phase="1"/>
</interactivity:Interaction.Behaviors>
</TextBlock>
<TextBlock
Text="{Binding Description}"
TextWrapping="WrapWholeWords"
Pivot.SlideInAnimationGroup="2"
CommonNavigationTransitionInfo.IsStaggerElement="True"
Style="{ThemeResource ListViewItemContentTextBlockStyle}"
Margin="0,0,19,0">
<interactivity:Interaction.Behaviors>
<core:IncrementalUpdateBehavior Phase="2"/>
</interactivity:Interaction.Behaviors>
</TextBlock>
</StackPanel>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Then, I set NavigationCacheMode = NavigationCacheMode.Required in code-behind. When I navigate to ItemPage and go back. ListViewItems will become blank when you slide it and never show again. They just disappear like this:
Finally, I find out the problem. It is a bug.
Because in the IncrementalUpdateBehavior, it use a function called "FindContentTemplateRoot" to search the visual tree for associated object's ContentTemplateRoot. When I navigate to another page, it raise associated object's Unloaded event and search the visual tree again. But this time it failed because it parent had been unloaded. VisualTreeHelper.GetParent() returns null.
So, it cause a bug that this Behavior can't normally uncache the associated object. When page goes back, associated object caches again. So that the associated object's opacity and DataContext will set twice or more. It just messed up.

How to wrap a group of TextBlocks inside StackPanel?

This is my code.
<StackPanel Orientation="Horizontal">
<TextBlock Name="Link1" Text="this is link1"></TextBlock>
<TextBlock Name="Text1" Text=" some text "></TextBlock>
<TextBlock Name="Link2" Text="this is link2"></TextBlock>
<TextBlock Name="Text2" Text=" some other text "></TextBlock>
<TextBlock Name="Link3" Text="this is link3></TextBlock>
</StackPanel>
Now this StackPanel will go out of the screen. I want to wrap the contents of this to go into next line on screen end.
I am not using <Run> property of TextBlock for defining all this because I want to register Tap event for TextBlocks defined as Links in above code. Using Buttons and Hyperlinks is also not desired here. Also with Buttons I will be having the same issue of wrapping up the content.
I see three options here:
Use a RichTextBox
Hoist the WrapPanel from the Windows Phone Toolkit
Write your own Panel
I think #1 should be the preferred approach, assuming you can make it fit the requirements. A RichTextBox can contain plain text inline with Hyperlinks -- the latter does not expose a Tap event, but it does have Click which may suffice.
Failing that, #2 should also be fairly straightforward, and may suffice if you can work with the limitation that the WrapPanel will treat the TextBlocks as atoms (ie, it won't wrap intra-TextBlock text).
Approach #3 would allow more flexibility in theory, but it would take some amount of effort and expertise to implement. You also might face some hassles down the road when you might need to adapt your custom panel to new or unforeseen requirements.

How can I programmatically launch the toolkit datepicker on windows phone 8

I have this peace of code:
<toolkit:DatePicker x:Name="SchedulerDatePicker"
Grid.Column="1"
Background="White"
Foreground="Black"
BorderThickness="0.5,1,0.5,0.5"
BorderBrush="#77797A"
FontSize="18"
Value="">
</toolkit:DatePicker>
<Button Grid.Column="1"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Background="Transparent"
BorderThickness="0"
BorderBrush="Transparent"
Click="CalendarButton_Click">
<Image x:Name="ImageDatePicker"
HorizontalAlignment="Right"
Margin="0,0,0,0"
Style="{StaticResource InfoEllipseImage}"
Source="../../Assets/Icons/datepicker.png">
</Image>
</Button>
All this code is inside a .xaml file in a project on Windows Mobile 8. I need to open the DatePicker 'SchedulerDatePicker' inside 'CalendarButton_Click' in code behind. How to do this? I really don't know...
Take a look at point 6 here.
This looks like what you need. Make a subclass of DatePicker as shown in point 6 of that blog post, use your subclass instead of the original DatePicker, and when you want to open it - call the ClickTemplateButton method. Oh, and don't forget to say thanks to the guy who wrote that blog post. :P
For some reason a method to open the picker was not added to the toolkit. You can take a look at its source code somewhere here.
If you are programatically trying to show the DatePickerPage, you could also invoke the private method to do this in the toolkit. Something like this.
typeof(Microsoft.Phone.Controls.DateTimePickerBase).InvokeMember ("OpenPickerPage", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, Type.DefaultBinder, this, null);

How to edit ExpandableContentTemplate in Blend

I'm using Telerik RadExpanderControl in my Wp8 app. I open the project in Blend, right-click the RadExpanderControl under Objects and Timeline, select Edit Additional Templates. Here my options are Edit Generated Content (ContentTemplate), Edit AnimatedIndicatorContentTemplate and Edit ExpandedStateContentTemplate.
None of these actually provide me access to the ExpandableContentTemplate which is what I need.
Am I missing something?
Unfortunately, is isn't available as an extractable template. However you can do this to create one:
<telerikPrimitives:RadExpanderControl.ExpandableContentTemplate>
<DataTemplate>
<StackPanel Margin="24, 4, 4, 4" Orientation="Horizontal">
<TextBlock
FontSize="{StaticResource PhoneFontSizeExtraLarge}"
FontFamily="{StaticResource PhoneFontFamilyLight}"
Text="{Binding TextYouWantToBind}"
VerticalAlignment="Center"/>
</StackPanel>
</DataTemplate>
</telerikPrimitives:RadExpanderControl.ExpandableContentTemplate>
A workaround that I do when I need to use Blend to style the ExpandableContentTemplate is to style the DataTemplate of the (Generated)ContentTemplate to my liking, then copy paste it into the DataTemplate of the ExpandablecontentTemplate.
I have reported this to the windows Phone Team