How to change listpicker dropdown ItemTemplate background? - xaml

I have a Windows Phone 8 listpicker that I'm trying to change the background color of, however, it only seems to change the item background and not the dropdown box background as you can see in the screen capture. The dropdown box seems to be binded to the WP8 theme. How can I change the background of the entire dropdown box and not just each individual item?
<toolkit:ListPicker x:Name="BackgroundListPicker" Background="Black" ItemsSource="{Binding BackgroundsList}">
<toolkit:ListPicker.ItemTemplate >
<DataTemplate x:Name="BackgroundItemTemplate" >
<Grid HorizontalAlignment="Stretch" Background="Black" VerticalAlignment="Stretch" Margin="0,0,0,0">
<StackPanel Orientation="Horizontal">
<Image Source="{Binding BackgroundThumb}" Width="30" Height="30" HorizontalAlignment="Left" />
<TextBlock Text="{Binding BackgroundName}" Foreground="White" Margin="12,0,0,0" HorizontalAlignment="Right"/>
</StackPanel>
</Grid>
</DataTemplate>
</toolkit:ListPicker.ItemTemplate>
</toolkit:ListPicker>

So your issue was that you were attempting to apply an image to an item. When you needed to hit the control itself that the items populate via ItemsPresenter so by pulling out the default style template for the control, and either making a place to pass in your image for an instance, or placing one directly into the template itself. You get your resulting background image for the ListPicker background to fall behind the items populating it.
Glad you found your remedy! Cheers.

Related

Apply Parallax effect into GridView

https://learn.microsoft.com/en-us/windows/uwp/design/motion/parallax
this is microsoft instruction to use the paralax they use the ListView to demo the effect
but my data is stored inside the Grid.View so can anyone show me how to implement into it ?
Microsoft said that we can use this with any element that contain the scrollviewer
ParallaxView works with GridView. The Source property of ParallaxView is for setting the element that either is or contains the ScrollViewer that controls the parallax operation. Here in your code snippet it bind the ForegroundElement to Source property but no such an element in. You need to name the GridView as ForegroundElement .
<GridView
x:Name="ForegroundElement"
IsItemClickEnabled="True"
ItemClick="Grid_Clicked"
ItemsSource="{x:Bind Icons}">
...
</GridView>
Besides this, the code snippet should work well. If you still cannot see the effects it may be caused by items count is not enough. ScrollViewer inside the GridView or ListView only be shown when the host control's layout space is being constrained smaller than the expanded content size, details please see ScrollViewer in a control template. You could try to add more items to check the effects.
Additionally, edit the question to add more details and avoid to put it as an answer.
<GridView Grid.Row="1" ItemsSource="{x:Bind Icons}" IsItemClickEnabled="True" ItemClick="Grid_Clicked">
<GridView.ItemTemplate>
<DataTemplate x:DataType="data:Icon">
<StackPanel>
<Image Width="200" Height="200" HorizontalAlignment="Center" Source="{x:Bind ImageCover}"/>
<TextBlock FontSize="16" VerticalAlignment="Center" Text="{x:Bind Title}"/>
<TextBlock FontSize="10" VerticalAlignment="Center" Text="{x:Bind Room}"/>
</StackPanel>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
this is where the data stored
and this is the parallax
<ParallaxView Source="{x:Bind ForegroundElement}" VerticalShift="50">
<!-- Background element -->
<Image x:Name="BackgroundImage" Source="Assets/turntable.png"
Stretch="UniformToFill"/>
</ParallaxView>

Screen does not display full content of string

i'm using the textblock to display the content,but for the long content, it just cut off and not display the content fully while i'm sure that the i filled the content string. Pls show me where my code is wrong. Thanks
Link of the my screen: www.flickr.com/photos/37903269#N05/15332152972/
my xaml code :
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<!-- <phone:WebBrowser VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Name="webBrowser1" /> -->
<ListBox Name="Listbox_DetailPage">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Content}"
TextWrapping="Wrap"
Style="{StaticResource PhoneTextNormalStyle}"
HorizontalAlignment="Center"
/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Grid>
I executed the code shared and it seems to wrap text as shown in the screen shot below.
The screenshot you shared seems to have vertical cropping of the text as well. For that, we can set the ScrollViewer.VerticalScrollBarVisibility to 'Auto' with proper Height given.
Also, for your additional knowledge or may be future use, here are some stackoverflow questions which explains the text 'NOT WRAPPING' issue for StackPanel
TextBlock TextWrapping not wrapping inside StackPanel
TextBlock TextWrapping not wrapping
actually, i fixed it.Because of the limitation of sing UI: 4096px limit of size. So there is a need to split the long content in the more than one TextBlock or you can create a scrollabe textbock as here

How to Change Radiobutton Icon against theme set in Windows Phone 8

In my application I am using not using windows default theme color for background instead of this I have used White color is my default. Now I am changing the content colors of the controls. Now all others are working good but in RadioButton I am getting some issue to set the RadioButton Icon color as it is still showing white according to phone theme(Phone theme is Black)
Do I need to set any external style for that? Can anyone please guide how I will achieve this?
Here is my code:
<ListBox Name="lstPollsQuestion" Grid.Row="1">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<RadioButton Name="rdbBlockTitle"
Margin="0,0,0,-20"
Height="72"
GroupName="PollQuestion"
Click="RadioButton_Click"
FontFamily="Segoe WP Light"
Tag="{Binding Path=questionId}">
<RadioButton.Content>
<TextBlock Text="{Binding Path=question}" Foreground="Black"/>
</RadioButton.Content>
</RadioButton>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
screenshot of the page
If we take a look at the default template for the RadioButton towards the bottom there's an Ellipse named "CheckGlyph" with Fill="{ThemeResource RadioButtonForegroundThemeBrush}" declared. So you can change it on the template level or that particular resource color.

Get Popup new target origin when screen edge is encountered

I have an issue with popup placement and especially the target origin.
I want to apply a Metro UI style to my combobox so there's no border between the textbox and the itemslist.
It works well when the popup is placed at the bottom
Placement="Bottom"
but when it encounters the bottom edge of the screen the target origin becomes the top of the placement target.
I'd like to know when the target origin changes to the top left corner, that way i could change the borderthickness of the control. Unfortunately the placement property is not reset to the new target origin so I'm a bit lost here.
Here's the code of the usercontrol.
The placement is set to custom here, it's the only workaround i've found to have something that suits me. But if I want metro like comboboxes I need to know where the popup really shows up...
<Grid>
<formElement:LabelBoxPC x:Name="NameFilter"
LabelName="{Binding FilterLabel,
ElementName=UCInlineFilterPreSelected}"
TextBoxCommand="{Binding GoToEntityManagementCommand}"
TextBoxValue="{Binding SearchValue,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}">
<formElement:LabelBoxPC.InputBindings>
<KeyBinding Key="F4" Command="{Binding GoToEntityManagementCommand}" />
</formElement:LabelBoxPC.InputBindings>
</formElement:LabelBoxPC>
<Popup x:Name="ResultsGrid"
Placement="Custom"
IsOpen="{Binding ElementName=NameFilter, Path=TextBoxFocus, Mode=OneWay}"
AllowsTransparency="True"
Focusable="False"
PopupAnimation="None">
<StackPanel>
<Border Padding="5px" Background="#FFF" BorderBrush="#000000" BorderThickness="2,2,2,0">
<Button HorizontalAlignment="Right" Style="{StaticResource SmallIconButton}" Background="{StaticResource DarkCloseIcon}"></Button>
</Border>
<ListBox x:Name="Results"
Width="220"
Style="{StaticResource InlineFilterListBox}"
Height="150"
ItemsSource="{Binding Results}"
SelectedItem="{Binding SelectedObject, ElementName=UCInlineFilterPreSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</Popup>
</Grid>

Binding Hyperlink to richtextblock in windows 8 Metro app

I am building a windows 8 metro app for fun/learning etc.
I have created a listview of text items that have descriptions, images etc. Inside the description, there are often hyperlinks that I would like to make clickable.
However, when binding to a textblock, xaml hyperlink code is displayed as text. Searching arround, it looks like I need to use a richtextblock for hyperlinks. I can't seem to figure out how to bind a hyperlink to it. I have found many examples from wpf showing how to extend the richtextblock using flowdocument. Flowdocument doesn't exist in the current consumer preview version of the framework.
I am reaching out to see if anyone has solved this issue or has any suggestions on what path to head down.
Edit:
Code I have Currently
right now I am just binding the "text" field from my Statuses Object to a textblock binding on "text"
I have URL's in the text field which I want to be able to make clickable.
As a test I was replacing the text field of the first object with hyperlink markup
ex.
feed_results[0].text = "<hyperlink .....
then trying to bind to texblock and richtextblock
Xaml
<ListView x:Name="ItemListView" ItemsSource="{Binding}" Background="Black" Width="372" VerticalAlignment="Top" Margin="50,0,0,0">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical" MinHeight="100">
<StackPanel Orientation="Horizontal">
<Image Source="{Binding user.profile_image_url}" Margin="0,0,15,0" VerticalAlignment="Top" />
<StackPanel Orientation="Vertical">
<TextBlock HorizontalAlignment="Left" Foreground="Gray" Text="{Binding user.name}" FontWeight="Bold" TextWrapping="Wrap" MaxWidth="200" />
<TextBlock HorizontalAlignment="Left" Foreground="Gray" Text="{Binding text}" TextWrapping="Wrap" MaxWidth="200" />
</StackPanel>
</StackPanel>
<StackPanel Margin="0,15,0,0" HorizontalAlignment="Right">
<TextBlock Text="{Binding created_at, Converter={StaticResource StringConverter},ConverterParameter=Released: \{0:d\}}" HorizontalAlignment="Center" Foreground="Gray" />
</StackPanel>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
Backend Code
FeedResult<Statuses> r2 = await feed.StatusesAsync(1, 50);
if (!r2.HasError)
{
feed_results = r2.Result;
Dispatcher.Invoke(Windows.UI.Core.CoreDispatcherPriority.High, new Windows.UI.Core.InvokedHandler((o, a) =>
{
ItemListView1.ItemsSource = feed_results;
}), this, null);
}
Microsoft removed support for inline hyperlinks from Metro XAML. You can still use HyperlinkButton for non inline hyperlinks, or if your inline hyperlinks short (1-2 words) then you could place HyperlinkButton inside of InlineUIContainer in RichTextBlock. Later solution would require some code, just using binding won't do it.