I want to align the contents or items of ExpanderView in horizontal layout instead of vertical layout. The ExpanderHeader is set dynamically and also its contents are added dynamically.
The xaml part and CustomeItemTemplate in app.xaml is as below
<toolkit:ExpanderView
Width="470"
Header="{Binding TaskName, Mode=TwoWay}"
x:Name="taskNameExpander"
Margin="5,10,5,10"
Foreground="#FF677389" FontSize="24" VerticalAlignment="Top"
HorizontalAlignment="Left"
ItemsSource="{Binding dateTime}"
ItemTemplate="{StaticResource CustomItemTemplate}"
HorizontalContentAlignment="Left">
</toolkit:ExpanderView>
<DataTemplate x:Key="CustomItemTemplate">
<StackPanel Orientation="Horizontal" Height="60" >
<TextBlock FontSize="16" Text="{Binding Date, Mode=OneWay}"
TextWrapping="Wrap" Foreground="#FF677389" Margin="0,6,0,0" Height="30" Width="100"/>
<TextBox BorderBrush="Goldenrod" BorderThickness="1" FontSize="16" Text="{Binding Time, Mode=TwoWay}" TextWrapping="Wrap" Foreground="#FF677389" Margin="0" Height="60" Width="150"/>
</StackPanel>
</DataTemplate>
Still i get the contents aligned vertically. Can someone point me what am i doing wrong here?
here is the sample code you have asked for
<Border BorderBrush="White" BorderThickness="1" Margin="5">
<ScrollViewer Width="Auto" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Disabled">
<toolkit:ExpanderView
Width="1600"
Header="{Binding TaskName, Mode=TwoWay}"
x:Name="taskNameExpander" Margin="5,10,5,10" Foreground="#FF677389" FontSize="24" VerticalAlignment="Top" HorizontalAlignment="Left"
ItemsSource="{Binding dateTime}"
ItemTemplate="{StaticResource CustomItemTemplate}"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
HorizontalContentAlignment="Left">
<toolkit:ExpanderView.ItemsPanel>
<ItemsPanelTemplate >
<StackPanel Orientation="Horizontal" Width="Auto" ScrollViewer.HorizontalScrollBarVisibility="Visible"/>
</ItemsPanelTemplate>
</toolkit:ExpanderView.ItemsPanel>
</toolkit:ExpanderView>
</ScrollViewer>
</Border>
and my app.xaml has CustomItemTemplate definition as below
<DataTemplate x:Key="CustomItemTemplate">
<StackPanel Orientation="Vertical" Height="100" >
<TextBlock FontSize="16" Text="{Binding Date, Mode=OneWay}" TextWrapping="Wrap" Foreground="#FF677389" Margin="0,6,0,0" Height="30" Width="100"/>
<TextBox BorderBrush="Goldenrod" BorderThickness="1" FontSize="16" Text="{Binding Time, Mode=TwoWay}" TextWrapping="Wrap" Foreground="#FF677389" Margin="0" Height="60" Width="150">
<TextBox.InputScope>
<InputScope >
<InputScopeName NameValue="Number"></InputScopeName>
</InputScope>
</TextBox.InputScope>
</TextBox>
</StackPanel>
</DataTemplate>
I want to horizontally scroll only ExpanderView items. Rightnow it is scrolling but the whole ExpanderView is scrolling including its header. The header must be intact and only the items must scroll. How can i acheive it?
You should set the ItemsPanel for the ExpanderView control.
<toolkit:ExpanderView
Width="470" Height="100"
x:Name="taskNameExpander"
Margin="5,10,5,10"
FontSize="24" Background="White"
HorizontalAlignment="Left"
ItemsSource="1 2 3 4"
ItemTemplate="{StaticResource CustomItemTemplate}"
HorizontalContentAlignment="Left">
<toolkit:ExpanderView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</toolkit:ExpanderView.ItemsPanel>
</toolkit:ExpanderView>
Related
So I'm having a issue with GroupHeaderPlacement and Vertical scrolling.
What Im trying to achieve is this:
But for some reason my groups are getting arranged in a horisontal scrolling direction. Anyone know if I'm missing something obvious here or if you simple can't have a vertical scrolling Listview if you have GroupHeaderPlacement Left.
The Code is:<ListView x:Name="ItemsGridView"
Margin="118,-5,0,0"
ItemsSource="{Binding Source={StaticResource AllCurrentGroup}}"
SelectionMode="Single"
Grid.Row="2"
Grid.Column="0"
ShowsScrollingPlaceholders="False"
SelectionChanged="SelectedPresentationItem_SelectionChanged"
IsSwipeEnabled="True">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid GroupHeaderPlacement="Left" Orientation="Vertical" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Grid.Column="1" Height="80" Margin="40,0,0,0" >
<TextBlock Text="{Binding Tid }" Style="{StaticResource BodyTextBlockStyle}" Grid.Column="1" >
<TextBlock.Foreground>
<SolidColorBrush Color="{StaticResource Orange}"/>
</TextBlock.Foreground>
</TextBlock>
<TextBlock Text="{Binding Titel }" Style="{StaticResource SubheaderTextBlockStyle}" Grid.Column="1" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<StackPanel Grid.Column="0" Grid.RowSpan="{Binding Rows}" Width="160" Height="200">
<StackPanel.Background>
<SolidColorBrush Color="{StaticResource BlueDark}"/>
</StackPanel.Background>
<TextBlock Text="{Binding Vecka, Converter={StaticResource ToWeekString }}" Style="{StaticResource BodyTextBlockStyle}" Foreground="#FFFFFFFF" HorizontalAlignment="Left" VerticalAlignment="Top" FontFamily="Global User Interface" Margin="20,13,0,0"/>
<TextBlock Text="{Binding Datum, Converter={StaticResource ToDayNumber }}" Style="{StaticResource HeaderTextBlockStyle}" Foreground="#FFFFFFFF" HorizontalAlignment="Left" Margin="20,26,0,0"/>
<TextBlock Text="{Binding Datum, Converter={StaticResource ToMonth }}" Style="{StaticResource SubheaderTextBlockStyle}" Foreground="#FFFFFFFF" HorizontalAlignment="Left" VerticalAlignment="Top" FontFamily="Global User Interface" Margin="20,-3,0,0"/>
<TextBlock Text="{Binding Datum, Converter={StaticResource ToDayString }}" Style="{StaticResource BodyTextBlockStyle}" Foreground="#FFFFFFFF" HorizontalAlignment="Left" VerticalAlignment="Top" FontFamily="Global User Interface" Margin="20,13,0,0"/>
</StackPanel>
</DataTemplate>
</GroupStyle.HeaderTemplate>
<GroupStyle.Panel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Vertical"></WrapGrid>
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</ListView.GroupStyle>
</ListView>
http://code.msdn.microsoft.com/windowsapps/GroupedGridView-77c59e8e/sourcecode?fileId=44751&pathId=298223712
Please refer the above sample link which helps you to achieve your req.
In my WP8 project textblock is cutting text unexpectedly. How can I solve it? I have used VerticalAlignment Strecth or Height auto in scrollviewer but they have not solve it.
And my xaml, I am using one of these stackpanels :
<ScrollViewer>
<Grid>
<StackPanel x:Name="stackNormal" Visibility="Collapsed" VerticalAlignment="Top" Background="Transparent">
<ListBox Name="ImageList" ItemsSource="{Binding Summary.Text , Converter={StaticResource ImageFromRssText}}" ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemTemplate>
<DataTemplate>
<Image Source="{Binding URL}" Tag="{Binding Title}" Margin="5,15,0,0"></Image>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<TextBlock TextDecorations="Underline" MouseLeftButtonUp="feedTitle_MouseLeftButtonUp" FontSize="25" Name="feedTitle" TextWrapping="Wrap" HorizontalAlignment="Stretch" Foreground="{StaticResource PhoneAccentBrush}" Text="{Binding Title.Text, Converter={StaticResource RssTextTrimmer}}" VerticalAlignment="Top" Margin="5,3,0,2" />
<TextBlock Name="feedSummary" TextWrapping="Wrap" Margin="5,0,15,0" Text="{Binding Summary.Text, Converter={StaticResource RssTextTrimmerLong}}" HorizontalAlignment="Stretch" FontSize="20" VerticalAlignment="Stretch"/>
<TextBlock Name="feedPubDate" Foreground="{StaticResource PhoneSubtleBrush}" Margin="12,20,0,5" Text="{Binding PublishDate.DateTime}" HorizontalAlignment="Center" />
</StackPanel>
<StackPanel x:Name="stackPhotoBug" Visibility="Collapsed" VerticalAlignment="Top" Background="Transparent">
<ListBox Name="ImageList2" ItemsSource="{Binding Links}" ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemTemplate>
<DataTemplate>
<Image Source="{Binding Converter={StaticResource ImagesFromRssTextForPhotoBug}}" HorizontalAlignment="Stretch" Margin="5,15,0,0" MaxHeight="500"></Image>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<TextBlock TextDecorations="Underline" MouseLeftButtonUp="feedTitle_MouseLeftButtonUp" FontSize="25" Name="feedTitle2" TextWrapping="Wrap" HorizontalAlignment="Stretch" Foreground="{StaticResource PhoneAccentBrush}" Text="{Binding Title.Text, Converter={StaticResource RssTextTrimmer}}" VerticalAlignment="Top" Margin="5,3,0,2" />
<TextBlock Name="feedSummary2" TextWrapping="Wrap" Margin="5,0,15,0" Text="{Binding Summary.Text, Converter={StaticResource RssTextTrimmerLong}}" HorizontalAlignment="Stretch" FontSize="20" VerticalAlignment="Stretch"/>
<TextBlock Name="feedPubDate2" Foreground="{StaticResource PhoneSubtleBrush}" Margin="12,20,0,5" Text="{Binding PublishDate.DateTime}" HorizontalAlignment="Center" />
</StackPanel>
</Grid>
</ScrollViewer>
Maybe it is because of such big text (TextBlock has limit - 2048px). You should try ScrollableTextBlock
Place the textblock inside scrollviewer
<scrollviewer verticalBarvisibility="visible">
<TextBlock Name="feedSummary" TextWrapping="Wrap"
Text="{Binding Summary.Text, Converter={StaticResource RssTextTrimmerLong}}"
HorizontalAlignment="Stretch" FontSize="20"
VerticalAlignment="Stretch"/>
</scrollviewer>
Any element that must be displayed beyond the area which is larger than 2048x2048 pixels would be clipped by the platform
Creating Scrollable TextBlock for WP7.
I'm trying to put two Grids in a DataTemplate.
I'm getting the following error with my code shown below.
Error: "The property 'VisualTree' is set more than once"
<DataTemplate x:Key="PareoItemTemplate">
<Grid x:Name="gridColorEjercicio" Height="100" Width="350" Background="#FFF0F0F0" Margin="-11,0,0,0">
<StackPanel Margin="0" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel Margin="0,10,15,0" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" Text="{Binding letter}" FontSize="24" FontFamily="Resources/Fonts/Programa Tutorias Bold.ttf#Programa Tutorias" Foreground="Black" VerticalAlignment="Center"/>
<TextBlock TextWrapping="Wrap" Text="{Binding option}" FontSize="24" FontFamily="Resources/Fonts/Programa Tutorias Bold.ttf#Programa Tutorias" Width="253" Foreground="Black" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
<Grid VerticalAlignment="Center" Margin="5,10,5,0" HorizontalAlignment="Center">
<Image Source="{Binding imageURI}" />
</Grid>
</StackPanel>
</Grid>
<Grid x:Name="gridPareoColorEjercicio" Height="100" Width="350" Background="#FFF0F0F0" Margin="-11,0,0,0">
<StackPanel Margin="0" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel Margin="0,10,15,0" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" Text="{Binding letter}" FontSize="24" FontFamily="Resources/Fonts/Programa Tutorias Bold.ttf#Programa Tutorias" Foreground="Black" VerticalAlignment="Center"/>
<TextBlock TextWrapping="Wrap" Text="{Binding option}" FontSize="24" FontFamily="Resources/Fonts/Programa Tutorias Bold.ttf#Programa Tutorias" Width="253" Foreground="Black" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
<Grid VerticalAlignment="Center" Margin="5,10,5,0" HorizontalAlignment="Center">
<Image Source="{Binding imageURI}" />
</Grid>
</StackPanel>
</Grid>
</DataTemplate>
A data template can only have one visual tree but you are defining two grids. If you want the two grids to appear next to each other or one below the other, wrap them in a StackPanel and set the property Orientation accordingly.
<DataTemplate>
<StackPanel Orientation="Vertical">
<Grid>[...]</Grid>
<Grid>[...]</Grid>
</StackPanel>
</DataTemplate>
The below given is the code which use getting each row of a list,
<ListBox x:Name="List" HorizontalAlignment="Left" Height="575" Margin="6,0,0,0" VerticalAlignment="Top" Width="443" SelectionChanged="List_SelectionChanged_1">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Width="430" Height="80">
<Grid Margin="0,0,0,0" Height="90" Width="305">
<TextBlock HorizontalAlignment="Left" Height="60" Margin="0,0,0,0" FontWeight="Medium" TextWrapping="Wrap" Text="{Binding Name}" VerticalAlignment="Top" Width="268" FontSize="25"/>
<TextBlock HorizontalAlignment="Left" Height="60" Margin="0,36,0,-1" TextWrapping="Wrap" Text="{Binding TaxType}" VerticalAlignment="Top" Width="259" Foreground="Gray" FontSize="16"/>
</Grid>
<StackPanel Orientation="Horizontal" Margin="0,0,0,0" FlowDirection="RightToLeft" Grid.Row="0" Width="125" HorizontalAlignment="Right">
<TextBlock Text="{Binding Percentage}" FontSize="23" VerticalAlignment="Center" HorizontalAlignment="Right" FontFamily="Portable User Interface" Height="75"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Now how can i draw a line at the end of this stack panel(i.e between each row in the list)
What you have to do is,Add your current data within the stackpanel and then add Path mentioned in the previous answer and place these two within a stackpanel with Orientation = Horizontal
In your StackPanel underneath all other, apply this:
<Path Data="M0,0 L1,1 M0,1 L1,0" Stretch="Uniform" Stroke="Red" />
have a semantic zoom control in an application where I've got three groups (today, tomorrow and later), but the groups don't necessarily always have at least one item. The semantic zoom control works perfect when all three groups are non-empty, but not whenever any of the items are empty. I've tried clearing out my DataTemplate to ensure it's nothing to do with the bindings, and I couldn't find an event to hook on to so that I could potentially step through what was going on when the zoom-out event is triggered.
Has anyone got this working, or have any ideas/suggestions/tips/workarounds?
some code:
XAML - collectionviewsource:
<!-- Collection of grouped items displayed by this page -->
<CollectionViewSource
x:Name="groupedItemsViewSource"
Source="{Binding Groups}"
IsSourceGrouped="True"
ItemsPath="Items"
d:Source="{Binding ItemGroups, Source={d:DesignInstance Type=data:AuctionDataSource, IsDesignTimeCreatable=True}}"/>
XAML - semantic zoom control:
<SemanticZoom Visibility="Collapsed" Grid.Row="1" Name="MainSemanticZoom">
<SemanticZoom.ZoomedInView>
<GridView
x:Name="itemGridView"
AutomationProperties.AutomationId="ItemGridView"
AutomationProperties.Name="Grouped Items"
Margin="116,0,40,46"
ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
SelectionMode="Multiple"
SelectionChanged="itemGridView_SelectionChanged_1">
<GridView.ItemTemplate>
<DataTemplate>
<Grid HorizontalAlignment="Left" Width="250" Height="200" RightTapped="Grid_RightTapped_1" Tag="{Binding}">
<Border Background="{StaticResource ListViewItemPlaceholderRectBrush}">
<Image Source="{Binding Image}" Stretch="UniformToFill"/>
</Border>
<StackPanel Grid.Column="1" VerticalAlignment="Bottom" Background="{StaticResource ListViewItemOverlayBackgroundBrush}">
<!--bindings: Title , CurrentBid, CloseDate -->
<TextBlock Text="{Binding Title}" Foreground="{StaticResource ListViewItemOverlayTextBrush}" Height="20" Style="{StaticResource TitleTextStyle}" Margin="15,0,15,0"/>
<TextBlock Text="{Binding CurrentBid, Converter={StaticResource FormatStringConverter}, ConverterParameter='\{0:C}'}" Foreground="{StaticResource ListViewItemOverlayTextBrush}" Style="{StaticResource TitleTextStyle}" TextWrapping="NoWrap" Margin="15,0,15,0"/>
<TextBlock Text="{Binding CloseDate, Converter={StaticResource FriendlyTimeConverter}}" Foreground="{StaticResource ListViewItemOverlayTextBrush}" Style="{StaticResource CaptionTextStyle}" TextWrapping="NoWrap" Margin="15,0,15,10"/>
<Border Visibility="{Binding IsLeading, Converter={StaticResource BooleanToVisibilityConverter}}" Name="leadingBlock" Background="CadetBlue">
<TextBlock Text="leading" Style="{StaticResource BodyTextStyle}" Margin="15,0,15,10"></TextBlock>
</Border>
<Border Visibility="{Binding IsOutbid,Converter={StaticResource BooleanToVisibilityConverter}}" Name="outbidBlock" Background="Orange">
<TextBlock Text="outbid" Style="{StaticResource BodyTextStyle}" Margin="15,0,15,10"></TextBlock>
</Border>
<Border Visibility="{Binding NoBids,Converter={StaticResource BooleanToVisibilityConverter}}" Name="noBidsBlock" Background="Gray">
<TextBlock Text="you have not placed a bid" Style="{StaticResource BodyTextStyle}" Margin="15,0,15,10"></TextBlock>
</Border>
</StackPanel>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<Grid Margin="5,0,30,10">
<!--<Button
AutomationProperties.Name="Group Title"
Content="{Binding Title}"
Click="Header_Click"
Style="{StaticResource TextButtonStyle}"/>-->
<TextBlock Text="{Binding Title}" Style="{StaticResource SubheaderTextStyle}"></TextBlock>
</Grid>
</DataTemplate>
</GroupStyle.HeaderTemplate>
<GroupStyle.Panel>
<ItemsPanelTemplate>
<VariableSizedWrapGrid Orientation="Vertical" Margin="0,0,80,0"/>
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</GridView.GroupStyle>
</GridView>
</SemanticZoom.ZoomedInView>
<SemanticZoom.ZoomedOutView>
<GridView
x:Name="itemZoomOutGridView"
AutomationProperties.AutomationId="ItemZoomOutGridView"
AutomationProperties.Name="Grouped Items"
SelectionMode="None">
<GridView.ItemTemplate>
<DataTemplate>
<Grid HorizontalAlignment="Left">
<Border Background="{StaticResource ListViewItemPlaceholderRectBrush}">
<Image Height="750" Source="{Binding Group.Image}" Stretch="UniformToFill"/>
</Border>
<StackPanel Height="140" Width="400" Background="Orange" VerticalAlignment="Center">
<TextBlock Margin="15" Text="{Binding Group.Title}" Foreground="White" Style="{StaticResource HeaderTextStyle}"></TextBlock>
<TextBlock Margin="15" Grid.Row="1" Text="{Binding Group.Items.Count}" Foreground="White" Style="{StaticResource HeaderTextStyle}"/>
</StackPanel>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Margin="230,0,0,0" Width="2000" Orientation="Horizontal"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
</SemanticZoom.ZoomedOutView>
</SemanticZoom>
I "solved" this by handling the ViewChangeStarted and the ViewChangeCompleted events of the SemanticView control. In the ViewChangeStarted event I added a new item, so that group won't be empty, and in the ViewChangedCompleted event I removed it. It's not a fix, just a workaround, but it does the job.
I don't think this is SemanticZoom issue. We reported very similar issue with GridView with grouped source. If any of the groups were empty we got exception. In fact CollectionViewSource is the likely culprit in this.
Our solution was not to use GridView with grouping. You can configure ItemsControl to look just like grouped GridView. The only downside to this is that you can't select items from different groups at the same time, but for us it was not an issue, since we didn't need selection.