I'm using the very popular LazyListBox from Peter Torr.
<lazy:LazyListBox x:name="lazy"> // cause error
<lazy:LazyListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Number}"></TextBlock>
</DataTemplate>
</lazy:LazyListBox.ItemTemplate>
<lazy:LazyListBox.LoadedItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Number}"></TextBlock>
<Image Source="{Binding ImageUri}"></Image>
</StackPanel>
</DataTemplate>
</lazy:LazyListBox.LoadedItemTemplate> </lazy:LazyListBox>
It gives me an error when i assigned name to listbox.
The type 'UIExtensionMethods.ISupportOffsetChanges' is defined in an assembly that is not referenced. You must add a reference to assembly 'UIExtensionMethods, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. D:\projectEG\Size4u(day1)\Size4u\Size4u\obj\Debug\Size4uView\HomePage.g.cs
You should add the reference to the dll in the project.
In Visual studio project explorer search for "References" and Add Reference.. Now i'm at phone so i don't remember the names bur search for references list.
Related
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
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).
In my mainpage.xaml I have a pivot control:
<Pivot x:Name="Pivot"
ItemsSource="{Binding PivotItems}"
ItemTemplate="{StaticResource PivotItemTemplate}">
</Pivot>
which binds it's items to a PivotsItems property on my viewmodel. The pivotitems are shown correctly but i'm not able to bind the content of the pivotitem.
My datatemplate looks like:
<DataTemplate x:Key="PivotItemTemplate">
<PivotItem>
<TextBlock Text="Test"></TextBlock>
</PivotItem>
</DataTemplate>
But no content is shown in any pivotitem.
What I wan't to do is to bind the pivotitems (which works) but show a seperate filter for each pivotitem. In this example I just want to show a TextBlock in each pivotitem.
SOLVED:
I defined the itemtemplate on the pivot control in the page, while i had to add it when populating the list in the vm:
PivotItems.Add(new PivotItem { Header = item.Key, ContentTemplate = App.Current.Resources["PivotItemTemplate"] as DataTemplate });
Pivot automatically Wraps it's items into PivotItems (like you don't add ListViewItem to a ListViews ItemsTemplate). Just put your content into the DataTemplate.
<DataTemplate x:Key="PivotItemTemplate">
<TextBlock Text="Test"></TextBlock>
</DataTemplate>
The header defaults to the DataContext of the PivotItem (so your list item). If you want it to display a certain property, you have to set the HeaderTemplate too:
<DataTemplate>
<TextBlock Text="{Binding MyProperty}" />
</DataTemplate>
If you just keep it as a TextBlock with no further properties, the default style gets applied perfectly.
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.
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