my list view inside the split view is not scrolling.
XAML code of total page goes like below.
<SplitView ScrollViewer.IsVerticalRailEnabled="True" BorderBrush="White" BorderThickness="1" x:Name="windowssplit1" DisplayMode="Overlay" Margin="40,-95,0,-200" Width="340" HorizontalAlignment="Left" x:FieldModifier="Public" Grid.RowSpan="2">
<SplitView.Pane>
<!--<Grid Background="Gray" ScrollViewer.VerticalScrollMode="Enabled" ScrollViewer.IsVerticalScrollChainingEnabled="True">-->
<StackPanel Background="Gray" BorderBrush="White" BorderThickness="1" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.IsVerticalScrollChainingEnabled="True" Margin="0,49,0,-162">
<TextBlock Text="All Ages" Margin="20,10,0,10" Foreground="White" FontSize="20" />
<Border BorderThickness="0.4" BorderBrush="White" Margin="20,0,0,10" Width="280" HorizontalAlignment="Left"/>
<ListView x:Name="filterlist1" Margin="10,0,0,0" ScrollViewer.VerticalScrollMode="Enabled" ScrollViewer.IsVerticalRailEnabled="True" SelectionChanged="filterlist_SelectionChanged">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock FontSize="18" Margin="0,10,0,0" Foreground="White" Text="{Binding CategoryName}"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<!--</Grid>-->
</StackPanel>
</SplitView.Pane>
</SplitView>
The List View present in the Bolded Code must Scroll how this can be done, Help me....
How to make the List scroll
i think you need to put your listview inside a scrolViwer !
I believe this has to do with the panel that the ListView is in. Set the ListView to have a 'fixed' MaxHeight so that it can know when to scroll.
<ListView x:Name="filterlist1" Margin="10,0,0,0"
ScrollViewer.VerticalScrollMode="Enabled"
ScrollViewer.IsVerticalRailEnabled="True"
SelectionChanged="filterlist_SelectionChanged"
MaxHeight="400">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock FontSize="18" Margin="0,10,0,0" Foreground="White" Text="{Binding CategoryName}"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
To make the ListView scrollable, we need give the ListView a explicit height or use a layout that can limit the height of ListView.
StackPanel is not suitable for this scenario as it won't limit the size of ListView. All items are showed in the ListView, but only these items in StackPanel can be seen.
We can use Grid instead of StackPanel and try with following code:
<SplitView x:Name="windowssplit1"
Grid.RowSpan="2"
Width="340"
HorizontalAlignment="Left"
BorderBrush="White"
BorderThickness="1"
DisplayMode="Overlay"
IsPaneOpen="True"
x:FieldModifier="Public">
<SplitView.Pane>
<Grid Background="Gray">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Margin="20,10,0,10"
FontSize="20"
Foreground="White"
Text="All Ages" />
<Border Width="280"
Margin="20,0,0,10"
HorizontalAlignment="Left"
BorderBrush="White"
BorderThickness="0.4" />
<ListView x:Name="filterlist1"
Grid.Row="1"
Margin="10,0,0,0"
SelectionChanged="filterlist_SelectionChanged">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Margin="0,10,0,0"
FontSize="18"
Foreground="White"
Text="{Binding CategoryName}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</SplitView.Pane>
</SplitView>
Here I set two rows in Grid and put the ListView in the second row. Second row's Height is set to * so it can get the rest Height of the Grid. I also remove the Margin in SplitView to see the scroll bar clearly.
Related
I have a stack panel which has another stack panel and I would like the second panel to be at the centre of first stack panel.I changed orientation of these panels and vertical alignment nothing works..
Anybody worked on this ? I would like to have your help.
Update:
<StackPanel Grid.Row="0" Grid.RowSpan="4" Background="White" Visibility="Visible" Orientation="Vertical">
<StackPanel VerticalAlignment="Center" Grid.Row="0">
<ProgressBar Margin="0,15,0,0"
IsIndeterminate="True"
IsEnabled="True" Foreground="Black"/>
<TextBlock Visibility="Visible" Margin="6,6,6,15" Foreground="Black" FontSize="21" TextWrapping="WrapWholeWords" HorizontalAlignment="Center" Text="Loading..."/>
</StackPanel>
</StackPanel>
The problem here is the StackPanel. What stack panel does is that it stacks the items from one side (top, left...) so it's not possible to fully center an item in StackPanel. When items are stacked vertically, the VerticalAlignment property has no effect on items that are direct children of the panel. The same applies for HorizontalAlignment and horizonal stacking.
You should use Grid or Border to center items (I also removed the Visibility values since Visible is the default state):
<Grid Grid.Row="0"
Grid.RowSpan="4"
Background="White"
>
<StackPanel HorizontalAlignment="Center"
VerticalAlignment="Center"
Grid.Row="0"
>
<ProgressBar Margin="0,15,0,0"
IsIndeterminate="True"
IsEnabled="True"
Foreground="Black"
/>
<TextBlock Margin="6,6,6,15"
Foreground="Black"
FontSize="21"
TextWrapping="WrapWholeWords"
HorizontalAlignment="Center"
Text="Loading..."
/>
</StackPanel>
</Grid>
Try this... You have to set Orientation to Horizontal of parent StackPanel.
<StackPanel Grid.Row="0" Grid.RowSpan="4" Background="White" Visibility="Visible" Orientation="Horizontal">
<StackPanel VerticalAlignment="Center" Grid.Row="0">
<ProgressBar Margin="0,15,0,0"
IsIndeterminate="True"
IsEnabled="True" Foreground="Black"/>
<TextBlock Visibility="Visible" Margin="6,6,6,15" Foreground="Black" FontSize="21" TextWrapping="WrapWholeWords" HorizontalAlignment="Center" Text="Loading..."/>
</StackPanel>
</StackPanel>
I'm trying to highlight the selected item in a bridview from a windows application.
To be more precise:
<GridView
x:Name="itemGridView"
AutomationProperties.AutomationId="ItemsGridView"
AutomationProperties.Name="Items"
TabIndex="1"
Grid.RowSpan="2"
Padding="116,136,116,46"
SelectionMode="None"
IsSwipeEnabled="false"
IsItemClickEnabled="True"
ItemClick="openRessource"
ItemsSource="{Binding Source={StaticResource itemsViewSource}}">
<GridView.ItemTemplate>
<DataTemplate>
<Grid HorizontalAlignment="Left" Width="200" Height="250" Holding="openHoldMenu">
<Border Background="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}">
<Image Source="{Binding icon}" Stretch="None"/>
</Border>
<Image Source="{Binding downloaded}" Width="30" Height="30" Margin="5" HorizontalAlignment="Right" VerticalAlignment="Top"/>
<StackPanel VerticalAlignment="Bottom" Background="{ThemeResource ListViewItemOverlayBackgroundThemeBrush}">
<TextBlock Text="{Binding Mode=OneWay}" Foreground="{ThemeResource ListViewItemOverlayForegroundThemeBrush}" Style="{StaticResource BaseTextBlockStyle}" Height="60" Margin="15,0,15,0" FontWeight="SemiBold"/>
<TextBlock Text="{Binding description, Mode=OneWay}" Foreground="{ThemeResource ListViewItemOverlaySecondaryForegroundThemeBrush}" Style="{StaticResource BaseTextBlockStyle}" TextWrapping="NoWrap" Margin="15,0,15,10" FontSize="12"/>
</StackPanel>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
This is my XAML, fairly simple, I just have a Holding event which brings up a menu in my page.
My problem is that I want to know which item has been held to create a border around it so that the user knows which item is selected.
I can easily access the bound item in my list but can't get the grid element selected.
If anyone know how to, that would be really appreciated.
Thank you!
Should be able to make a trigger such as this:
http://stackoverflow.com/questions/4539909/wpf-datagrid-selected-row-style
My problem is this:
I got this ListView -
<ListView ItemsSource="{Binding GameRow1}" ItemTemplate="{StaticResource GamePiecesTemplate}" VerticalAlignment="Bottom" Grid.Column="12" Grid.Row="1" />
and I got this Image -
<Image Grid.Column="12" Grid.Row="1" Source="/Images/Gray_triangle2.png" Stretch="Fill"/>
The problem is that the Image covers my ListView and I can't the ListView items. is there a way to set picture to be on a grid cell as background?
this is the ItemTemplate btw:
<DataTemplate x:Key="GamePiecesTemplate">
<StackPanel>
<Image Source="{Binding IsWhite , Converter={StaticResource GamePiceToImgSrc}}" Height="50" Width="50" ></Image>
<Label HorizontalAlignment="Center" Content="{Binding Path=UserName}" />
</StackPanel>
</DataTemplate>
Let me start by saying sorry if this is a duplicate. I was unable to find an answer in any of the similar posts that I have read. I am having an issue where I have a Border control whose Height and Width are bound to the ActualHeight and ActualWidth of a TextBlock that is a child of the Border.
Everything displays fine in the designer, but for some reason at run-time, the Border control is not visible. I am not sure if it is because the Height or Width may be 0, or perhaps the Visibility is being set some other way. If I hard code the Height/Width then everything displays the same in the designer and at runtime, but something is acting bizarre with this binding. Even more bizarre, is that they were working before, and I'm not sure what I could have done to break them. Here is my XAML:
<Grid Visibility="{Binding Path=Contacts.Count, Converter={StaticResource ItemCountToVisibilityConverter}}" >
<Border CornerRadius="5"
BorderBrush="White"
BorderThickness="2"
Padding="20,15,0,15"
Margin="0,15,0,15">
<ListView ItemsSource="{Binding Path=Contacts}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Path=Name}" />
<TextBlock Text="{Binding Path=Number}" />
<TextBlock Text="{Binding Path=EmailAddress}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Border>
<Border Background="White"
CornerRadius="5"
Height="{Binding Path=ActualHeight, ElementName=ContactsTextBlock}"
Width="{Binding Path=ActualWidth, ElementName=ContactsTextBlock}"
VerticalAlignment="Top">
<TextBlock Text="Contact Information"
x:Name="ContactsTextBlock"
Foreground="Black"
Padding="5,2,5,2"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
</Grid>
It is the second Border control in the XAML that is having the issue. As I said, it displays properly in the designer, but for some reason at runtime, the Border control as well as the TextBlock it contains are not visible. Also, the Grid is working properly, as well as the ListView and the first Border. It is simply the second Border and it's TextBlock that are not functioning properly.
Thanks in advance!
Here is what it looks like at design-time:
Let the Grid do the dirty work for you. I believe the Grid is one of the best controls WPF has.
The trick is dividing the vertical space in three slices, where the two on the top are sized accordingly to the desired space. That is, the TextBlock will determine how tall will be the row pair. You don't have to do anything than enjoying the result...
Here is a sample XAML (I cut the Visibility property for sake of simplicity):
<Grid Margin="40,20">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border
CornerRadius="5"
BorderBrush="White"
BorderThickness="2"
Padding="20,15,20,15"
Background="DimGray"
Grid.Row="1"
Grid.RowSpan="2"
>
<ListView ItemsSource="{Binding Path=Contacts}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Path=Name}" />
<TextBlock Text="{Binding Path=Number}" />
<TextBlock Text="{Binding Path=EmailAddress}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Border>
<Border
Background="White"
CornerRadius="5"
Grid.Row="0"
Grid.RowSpan="2"
HorizontalAlignment="Center"
>
<TextBlock
Text="Contact Information"
x:Name="ContactsTextBlock"
Foreground="Black"
Padding="5,2,5,2"
/>
</Border>
</Grid>
Please, note the ListView border is sharing the middle row, so that the borderline will run "striking" the text.
That renders as follows:
You may want to set up BorderThickness and BorderBrush:
<Border Background="White"
Border Background="White"
CornerRadius="5"
BorderThickness="1"
BorderBrush="Gray"
HorizontalAlignment="Center"
VerticalAlignment="Top">
<TextBlock Text="Contact Information"
x:Name="ContactsTextBlock"
Foreground="Black"
Padding="5,2,5,2"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
So I have this problem, a textblock's text gets cut off, even though you can still scroll with scrollviewer to the end.
You can see the scrollviewer is still able to scroll to where the text should be.
Heres the XAML:
<Grid>
<ScrollViewer Height="Auto" VerticalScrollBarVisibility="Auto" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" >
<TextBlock x:Name="text" Padding="5" Margin="0" TextWrapping="Wrap" Text="" FontSize="24" TextTrimming="WordEllipsis" VerticalAlignment="Bottom" />
</ScrollViewer>
</Grid>
EDIT the whole pivot control code:
<controls:Pivot x:Name="pivot" Margin="0" Grid.Row="1" Title="title" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch">
<controls:PivotItem Header="Straipsnis">
<Grid>
<ScrollViewer Height="Auto" VerticalScrollBarVisibility="Auto" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" >
<Border BorderBrush="White" BorderThickness="1">
<TextBlock x:Name="text" Padding="5" TextWrapping="Wrap" Text="" FontSize="24"/>
</Border>
</ScrollViewer>
</Grid>
</controls:PivotItem>
<controls:PivotItem Header="Komentarai">
<Grid>
<ListBox x:Name="commentsListBox" ItemTemplate="{StaticResource CommentsList}" Height="Auto" Width="Auto" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch" FontSize="20"/>
<TextBlock x:Name="errorText" TextWrapping="Wrap" Text="Nėra komentarų..." FontSize="36" HorizontalAlignment="Left" Margin="10,0,0,0"/>
</Grid>
</controls:PivotItem>
</controls:Pivot>
Well, turns out the TextBlock has limits, 2048x2048 or something like that, after which the text just gets cut off.
So, I found this custom text control that bypasses this limitation :) Maybe someone will find it useful, I did.
Creating Scrollable TextBlock for WP7.
Download link