Content Dialog wont change its size - c#

I have a Content Dialog that no matter what options I gave to it (width, height, fullscreen) seems like it would not grow beyond a certain width.
This is the XAML for Content Dialog:
<ContentDialog x:Name="CntdCommand" Title="Comanda" FullSizeDesired="True">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Grid.Column="0">
<ListView ItemsSource="{Binding SelectedHallTable.Command.CommandItems}">
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Width="48" Height="48">
<Image Source="../Assets/LoginBackground.jpg" Stretch="UniformToFill"/>
</Border>
<StackPanel Grid.Column="1" VerticalAlignment="Top" Margin="10,0,0,0">
<TextBlock Text="{Binding Product.Name}"></TextBlock>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Cantitate: "></TextBlock>
<TextBlock Text="{Binding Quantity}"></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Total: "></TextBlock>
<TextBlock Text="{Binding Total}"></TextBlock>
</StackPanel>
</StackPanel>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
<Grid Grid.Row="0" Grid.Column="1">
<Pivot ItemsSource="{Binding ProductGroups}" SelectedItem="{Binding SelectedProductGroup, Mode=TwoWay}">
<Pivot.ItemTemplate>
<DataTemplate x:DataType="views:ProductGrouping">
<GridView ItemsSource="{x:Bind}">
<!--<GridView.GroupStyle>
<GroupStyle HeaderTemplate="{StaticResource MenuHeaderTemplate}" />
</GridView.GroupStyle>-->
<GridView.ItemTemplate>
<DataTemplate x:DataType="viewModels:ProductDTOViewModel">
<Grid>
<StackPanel Padding="10">
<Image Source="../Assets/LoginBackground.jpg" Width="64" Height="64" />
<TextBlock Text="{x:Bind Name}"/>
<TextBlock Text="{x:Bind EAN}"/>
</StackPanel>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
</DataTemplate>
</Pivot.ItemTemplate>
</Pivot>
</Grid>
<Grid Grid.Row="1" Grid.Column="0">
<StackPanel Orientation="Horizontal">
<TextBlock Text="Total: "></TextBlock>
<TextBlock Text="{Binding SelectedHallTable.Command.Total}"></TextBlock>
</StackPanel>
</Grid>
<Grid Grid.Row="1" Grid.Column="1">
<CommandBar DefaultLabelPosition="Right">
<AppBarButton Icon="Delete" Label="Sterge" />
<AppBarSeparator></AppBarSeparator>
<AppBarButton Icon="Send" Label="Trimite" />
<AppBarButton Icon="Accept" Label="Incaseaza" />
</CommandBar>
</Grid>
</Grid>
</ContentDialog>
And this is how the result looks like:
I have tried to change its width and height but it doesn't do anything, any help would be appreciated. Thanks!

Set MaxWidth and it should work

Related

WPF: Limit ListBox's height to the height of grid row

Here's a part of my XAML:
<Grid HorizontalAlignment="Stretch"
Margin="10"
MaxHeight="{Binding Path=ActualHeight,
RelativeSource={RelativeSource AncestorType={x:Type Window}}}">
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TabControl Grid.Row="0" MinWidth="270" HorizontalAlignment="Stretch">
<TabItem Header="CPU">
<StackPanel Orientation="Vertical" >
<ListBox Name="CPUListBox"
ItemsSource="{Binding CPUCounters, Mode=OneWay}"
SelectionMode="Multiple"
MaxHeight="{Binding RelativeSource={RelativeSource
AncestorType={x:Type Grid}}, Path=ActualHeight}"
BorderThickness="1"
BorderBrush="#FF8B8B8B"
SelectionChanged="CPUListBox_SelectionChanged"
ScrollViewer.VerticalScrollBarVisibility="Visible">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock>
<Run Text="{Binding CounterName, Mode=OneWay}"/>
<Run Text="{Binding InstanceName, Mode=OneWay}"/>
</TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Grid Name="CPUSelectButtonsGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Name="CPUSelectAllButton"
Margin="0,10,0,0"
Click="CPUSelectAllButton_Click">
<TextBlock Text="SELECT ALL"/>
</Button>
<Button Grid.Column="1" Name="CPUUnSelectAllButton"
Margin="0,10,0,0"
Click="CPUUnSelectAllButton_Click">
<TextBlock Text="UNSELECT ALL"/>
</Button>
</Grid>
</StackPanel>
</TabItem>
<TabItem Header="Memory">
<StackPanel Orientation="Vertical">
<ListBox Name="RAMListBox"
ItemsSource="{Binding RAMCounters, Mode=OneWay}"
SelectionMode="Multiple"
BorderThickness="1"
BorderBrush="#FF8B8B8B"
SelectionChanged="RAMListBox_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock>
<Run Text="{Binding CounterName, Mode=OneWay}" />
<Run Text="{Binding InstanceName, Mode=OneWay}" />
</TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Grid Name="RAMSelectButtonsGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Name="RAMSelectAllButton"
Margin="0,10,0,0"
Click="RAMSelectAllButton_Click" >
<TextBlock Text="SELECT ALL"/>
</Button>
<Button Grid.Column="1" Name="RAMUnSelectAllButton"
Margin="0,10,0,0"
Click="RAMUnSelectAllButton_Click" >
<TextBlock Text="UNSELECT ALL"/>
</Button>
</Grid>
</StackPanel>
</TabItem>
</TabControl>
<StackPanel Grid.Row="1"
Orientation="Horizontal"
HorizontalAlignment="Right"
Margin="0,15,6,0">
<TextBlock Name="NumberOfSelectionsTextBlock" Text ="0"/>
<TextBlock Text=" items selected"/>
</StackPanel>
</Grid>
Here' what's wrong:
I have a ListBox in each tab of TabControl. When the number of elements in a ListBox is big, the ListBox covers the buttons and I can't get access to them. I tried limitting ListBox's Height to MaxHeight="{Binding RelativeSource={RelativeSource AncestorType={x:Type Grid}}, Path=ActualHeight}", but it's too much - it takes Height of the whole Grid, also covering the Buttons and TextBoxes below them. I'd like the whole thing to be dynamically resized with the Window, so that nothing gets cut off.
I can't find a proper solution to this. What should I do?
The issue here is your stack panel that grows when no of items grow. A better layout would be to use a WPF Grid where you can have two rows.
Second row will contain Buttons and that row can then be given fixed size where as the first row can be set as Width = *
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
</Grid>

C# - Listview Fullrowselect on UWP

I want do some things with my listview on my UWP project:
When a item of the listview is selected I want the entire row selected, also the subitems (cells) on the row should be not selectable.
I was trying with Fullrowselect but seem is not longer availiable in uwp.
my current xaml is:
<ListView x:Name="ListView1" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,164,0,0" BorderBrush="Black" BorderThickness="1" Background="WhiteSmoke" Visibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible" >
<ListView.ItemTemplate>
<DataTemplate>
<Grid Padding="0" Margin="0" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="130" />
<ColumnDefinition Width="300" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<TextBox x:Name="TextBox_Item" Grid.Column="0" Text="{Binding Path=Item}" TextWrapping="Wrap" BorderBrush="Black" BorderThickness="1.5" IsReadOnly="True" TextAlignment="Left"/>
<TextBox x:Name="TextBox_Name" Grid.Column="1" Text="{Binding Path=Name}" TextWrapping="Wrap" BorderThickness="1.5" BorderBrush="Black" IsReadOnly="True" TextAlignment="Left"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Any help is appreciated.
There's a property called "IsHitTestVisible, try changing it to false on your textboxes.
<ListView x:Name="ListView1" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,164,0,0" BorderBrush="Black" BorderThickness="1" Background="WhiteSmoke" Visibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible" >
<ListView.ItemTemplate>
<DataTemplate>
<Grid Padding="0" Margin="0" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="130" />
<ColumnDefinition Width="300" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<TextBox x:Name="TextBox_Item" Grid.Column="0" Text="{Binding Path=Item}" TextWrapping="Wrap" BorderBrush="Black" BorderThickness="1.5" IsReadOnly="True" TextAlignment="Left" IsHitTestVisible="False"/>
<TextBox x:Name="TextBox_Name" Grid.Column="1" Text="{Binding Path=Name}" TextWrapping="Wrap" BorderThickness="1.5" BorderBrush="Black" IsReadOnly="True" TextAlignment="Left" IsHitTestVisible="False"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>

Horizontal ListView items do not scroll when swiped in WinRT app?

I have a C# WinRT/8.1 app that uses a ListView with a child stack panel to show items in a horizontal row. That works fine, except I am having the same problem discussed in this SO post:
WinRT Xaml ListView - Touch doesn't scroll well
Except worse. My items don't scroll even when the fingertip is pressed on the margin between items. Unfortunately I don't have a parent Panorama control or ScrollView control to blame. How can I fix this?
NOTE: I switched to a ListView from a GridView because of SO posts I read that indicated GridView's with horizontal items are problematic, which was the case for me.
Here is the XAML for the page:
<Page
<!-- headers snipped for brevity -->
<Page.Resources>
<Converters:DebugBindingConverter x:Key="DebugBindingConverter"/>
<Converters:VideomarkLocationToString x:Key="VideomarkLocationToString"/>
<common:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<DataTemplate x:Key="HorzVideomarksItemTemplate1">
<Grid d:DesignWidth="977" d:DesignHeight="746" Height="121" Width="252">
<Grid.RowDefinitions>
<RowDefinition Height="20*"/>
<RowDefinition Height="52*"/>
<RowDefinition Height="23*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="txtLocation" TextWrapping="Wrap" Text="{Binding OffsetSecs, Converter={StaticResource VideomarkLocationToString}}" Grid.Row="2" />
<TextBlock x:Name="txtNote" Text="{Binding Text}" TextTrimming="CharacterEllipsis"/>
<Image x:Name="imgThumbnail" Grid.Row="1" Source="{Binding ThumbnailAsync}"/>
<!-- <TextBlock x:Name="txtTest2" HorizontalAlignment="Left" Margin="81,93,0,0" TextWrapping="Wrap"
Text="{Binding Videomarks, Converter={StaticResource DebugBindingConverter}}" VerticalAlignment="Top" Height="87" Width="150" FontSize="12"/> -->
</Grid>
</DataTemplate>
</Page.Resources>
<Grid x:Name="gridPage"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="25" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="897*"/>
<ColumnDefinition Width="469*"/>
</Grid.ColumnDefinitions>
<Grid.ChildrenTransitions>
<TransitionCollection>
<EntranceThemeTransition/>
</TransitionCollection>
</Grid.ChildrenTransitions>
<Grid.RowDefinitions>
<RowDefinition Height="140"/>
<RowDefinition Height="347*"/>
<RowDefinition Height="231*"/>
</Grid.RowDefinitions>
<!-- Back button and page title -->
<Grid x:Name="gridTopRow" Grid.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button x:Name="backButton" Margin="39,59,39,0" Command="{Binding NavigationHelper.GoBackCommand, ElementName=pageRoot}"
Style="{StaticResource NavigationBackButtonNormalStyle}"
VerticalAlignment="Top"
AutomationProperties.Name="Back"
AutomationProperties.AutomationId="BackButton"
AutomationProperties.ItemType="Navigation Button"/>
<TextBlock x:Name="pageTitle" Text="{StaticResource AppName}" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1" TextWrapping="NoWrap" VerticalAlignment="Bottom" Margin="0,0,894,40" Tapped="pageTitle_Tapped"/>
<Button x:Name="exitButton"
Click="exitButton_Click"
Style="{StaticResource ClosePaneAppBarButtonStyle}" Margin="1065,27,0,9" Grid.Column="1" Width="100" Visibility="{Binding Main.IsDebuggerAttached, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}" />
<Button x:Name="btnTest" Content="test" Grid.Column="1" HorizontalAlignment="Left" Margin="883,59,0,0" VerticalAlignment="Top" FontSize="36" Click="btnTest_Click" Visibility="Collapsed"/>
</Grid>
<WebView x:Name="webViewVideoPlayer" Grid.Row="1" ScriptNotify="ScriptNotifyPlayLocation" Margin="25" />
<Button x:Name="btnVideomark" Content="Bookmark" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="578,53,0,0" Height="54" FontSize="26.667" Click="btnVideomark_Click" Width="181"/>
<ListView
x:Name="listviewVideomarks" Grid.Row="2" Grid.ColumnSpan="2" Opacity="1" IsHitTestVisible="False" Margin="20"
ItemsSource="{Binding Videomarks.VideomarksCollection, Source={StaticResource Locator}}"
ItemTemplate="{StaticResource HorzVideomarksItemTemplate1}" SelectionMode="None"
>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel x:Name="stackVideomarksHorz" Orientation="Horizontal">
</StackPanel>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
<Border x:Name="borderAddVideomark" BorderThickness="5" Grid.ColumnSpan="2" Margin="369,53,319,112" Grid.Row="1" BorderBrush="#FF144989" CornerRadius="25" Opacity="0" IsHitTestVisible="False" Loaded="border_Loaded">
<Grid x:Name="gridAddVideomark" IsHitTestVisible="False" Grid.ColumnSpan="2" Grid.Row="1" Opacity="1" Grid.RowSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="187*"/>
<ColumnDefinition Width="188*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="189*"/>
<RowDefinition Height="137*"/>
<RowDefinition Height="62*"/>
</Grid.RowDefinitions>
<TextBlock x:Name="lblVideomarkLocation" Grid.Column="1" TextWrapping="Wrap" Text="TextBlock" Margin="40,10,10,10" FontSize="18.667"/>
<TextBox x:Name="txtVideomarkNote" Grid.Row="1" TextWrapping="Wrap" Grid.ColumnSpan="2" Margin="10,10,10,2"/>
<Button x:Name="btnOk" Content="OK" HorizontalAlignment="Left" Margin="92,10,0,0" Grid.Row="2" VerticalAlignment="Top" Width="192" Foreground="White" FontSize="21.333" Height="45" Click="btnOk_Click"/>
<Button x:Name="btnCancel" Content="Cancel" HorizontalAlignment="Left" Margin="88,10,0,0" Grid.Row="2" VerticalAlignment="Top" Width="192" Foreground="White" FontSize="21.333" Height="45" Grid.Column="1" Click="btnCancel_Click"/>
<Rectangle x:Name="rectVideomarkThumbnail" Fill="#FFF4F4F5" Stroke="Black" Margin="10"/>
</Grid>
</Border>
</Grid>
</Page>
I am not sure which directions you are trying to scroll, but I think your problem will be fixed if you disable the StackPanel scroll and enable scrolling in both directions on the ListView.
<ListView
x:Name="listviewVideomarks" Grid.Row="2" Grid.ColumnSpan="2" Opacity="1" IsHitTestVisible="False" Margin="20"
ItemsSource="{Binding Videomarks.VideomarksCollection, Source={StaticResource Locator}}"
ItemTemplate="{StaticResource HorzVideomarksItemTemplate1}" SelectionMode="None"
ScrollViewer.HorizontalScrollMode="Auto" ScrollViewer.VerticalScrollMode="Auto"
>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel x:Name="stackVideomarksHorz" Orientation="Horizontal"
ScrollViewer.HorizontalScrollMode="Disabled"
ScrollViewer.VerticalScrollMode="Disabled">
</StackPanel>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>

Page scrollbar windows 8

my problem is that I have only scrollbar for gridview but don't have scrollbar for entire page. Scrollbar should be at the bottom of the page, horizontal. I tried to add scrollbar to the bottom, but it doesn't appear on the page. I've also posted a link to the picture for better understanding. http://i40.tinypic.com/2rm0389.png Sorry that i have only a link, because i need 10 reputation to post images here, it is so bad.
Thanks in advance.
Here is my code (XAML), not entire page, my scrollbar at the bottom:
<!-- Back button and page title -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
<TextBlock x:Name="pageTitle" Text="Профиль" Grid.Column="1" IsHitTestVisible="false" Style="{StaticResource PageHeaderTextStyle}"/>
</Grid>
<Grid Width="Auto" Margin="0,5,0,0" Grid.Row="1"
>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="0*"/>
</Grid.ColumnDefinitions>
<Image Source="{Binding ProfileImage}" Stretch="UniformToFill" HorizontalAlignment="Left" Height="270" Margin="165,46,0,0" VerticalAlignment="Top" Width="225"/>
<TextBlock Text="{Binding Name}" HorizontalAlignment="Left" Margin="165,5,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="41" Width="252" FontSize="22" FontWeight="Bold"/>
<GridView x:Name="GridViewToFrinedsPhoto" Margin="461,0,0,0"
ItemsSource="{Binding Mode=TwoWay, Source={StaticResource groupedItemsViewSource}}"
ItemTemplate="{StaticResource MyPhotoItemTemplate}"
SelectionMode="Single"
IsItemClickEnabled="True"
IsSwipeEnabled="false" ItemClick="GridViewToFrinedsPhoto_ItemClick">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<Grid Margin="1,0,0,6">
<Button
x:Name="ColumnBtn"
AutomationProperties.Name="Group Title" AutomationProperties.LabeledBy="{Binding Title}"
Style="{StaticResource TextPrimaryButtonStyle}" Click="Button_Click_1">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Title}" Margin="3,-7,10,10" Style="{StaticResource GroupHeaderTextStyle}" />
<TextBlock Text="{StaticResource ChevronGlyph}" FontFamily="Segoe UI Symbol" Margin="0,-7,0,10" Style="{StaticResource GroupHeaderTextStyle}"/>
</StackPanel>
</Button>
</Grid>
</DataTemplate>
</GroupStyle.HeaderTemplate>
<GroupStyle.Panel>
<ItemsPanelTemplate>
<VariableSizedWrapGrid Orientation="Vertical" Margin="0,0,80,0"/>
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</GridView.GroupStyle>
</GridView>
<ScrollBar VerticalAlignment="Bottom" HorizontalAlignment="Center" Width="Auto" RenderTransformOrigin="0.588,-0.824" Visibility="Visible" Margin="0,0,0,603" Orientation="Horizontal" /> -- HERE IS MY SCROLLBAR, DOESN'T WORK :[
</Grid>
</Grid>
My Final code, i hope it helps someone else, I have used scrollviewer and grid container, thanks to Vishal Kaushik from MSDN
<common:LayoutAwarePage
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:VKClient.Views"
xmlns:common="using:VKClient.Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:vkControls="using:VKClient.VkControls"
xmlns:Controls="using:Callisto.Controls"
x:Name="pageRoot"
x:Class="VKClient.Views.ProfileViewPage"
DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Mode=Self}}"
mc:Ignorable="d">
<common:LayoutAwarePage.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary
Source="../Resources/MyStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
<CollectionViewSource x:Name="groupedItemsViewSource"
Source="{Binding Items, Mode=TwoWay}"
IsSourceGrouped="True"
ItemsPath="Items"/>
</ResourceDictionary>
</common:LayoutAwarePage.Resources>
<!--
This grid acts as a root panel for the page that defines two rows:
* Row 0 contains the back button and page title
* Row 1 contains the rest of the page layout
-->
<common:LayoutAwarePage.BottomAppBar>
<AppBar x:Name="BottomAppBar2" Padding="10,0,10,0">
<Grid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<Button x:Name="MyProfileButton" Style="{StaticResource MyProfileAppBarButtonStyle}" Click="MyProfileClicked" />
<Button x:Name="MyFriendsButton" Style="{StaticResource MyFriendsAppBarButtonStyle}" Click="MyFriendsClicked"/>
<Button x:Name="MyPhotoButton" Style="{StaticResource MyPhotoAppBarButtonStyle}" Click="MyPhotoClicked" />
<Button x:Name="MyVideosButton" Style="{StaticResource MyVideoesAppBarButtonStyle}" Click="MyVideoesClicked"/>
<Button x:Name="MyAudioButton" Style="{StaticResource MyAudioAppBarButtonStyle}" Click="MyAudioClicked"/>
<Button x:Name="MyGroupsButton" Style="{StaticResource MyGroupsAppBarButtonStyle}" Click="MyGroupsClicked"/>
<!-- <Button x:Name="MyMessagesButton" Style="{StaticResource MyMessagesAppBarButtonStyle}" Click="MyMessagesClicked"/>
<Button x:Name="MyNewsButton" Style="{StaticResource MyNewsAppBarButtonStyle}" Click="MyNewsClicked"
/> -->
</StackPanel>
</Grid>
</AppBar>
</common:LayoutAwarePage.BottomAppBar>
<Grid Style="{StaticResource LayoutRootStyle}" Background="{StaticResource AccentBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="140"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Horizontal scrolling grid used in most view states -->
<!-- Vertical scrolling list only used when snapped -->
<!-- Back button and page title -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
<TextBlock x:Name="pageTitle" Text="Профиль" Grid.Column="1" IsHitTestVisible="false" Style="{StaticResource PageHeaderTextStyle}"/>
</Grid>
<Grid Width="Auto" Margin="0,5,0,0" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="0*"/>
</Grid.ColumnDefinitions>
<ScrollViewer HorizontalScrollMode="Auto" HorizontalScrollBarVisibility="Auto"
VerticalScrollMode="Disabled" VerticalScrollBarVisibility="Disabled">
<Grid Width="Auto">
<Controls:LiveTile HorizontalAlignment="Left" Margin="20,101,0,0" VerticalAlignment="Top" Width="109" Height="137" Background="LightGreen">
<Controls:LiveTile.ItemTemplate>
<DataTemplate>
<Grid Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Button Style="{StaticResource MyGroupsAppBarButtonStyle}" Margin="0,0,0,41" Grid.RowSpan="2"/>
<HyperlinkButton
HorizontalAlignment="Right"
Foreground="LightGray"
Click="GroupClicked" Height="129" Grid.RowSpan="2" Width="90" />
</Grid>
</DataTemplate>
</Controls:LiveTile.ItemTemplate>
</Controls:LiveTile>
<Controls:LiveTile HorizontalAlignment="Left" Margin="20,273,0,0" VerticalAlignment="Top" Width="109" Height="151" Background="Violet">
<Controls:LiveTile.ItemTemplate>
<DataTemplate>
<Grid Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Button Style="{StaticResource MyAudioAppBarButtonStyle}" Margin="0,0,0,41" Grid.RowSpan="2"/>
<HyperlinkButton
HorizontalAlignment="Right"
Foreground="LightGray"
FontSize="9" FontWeight="Bold" Click="ProfileAudios" Height="139" Grid.RowSpan="2" Width="99" />
</Grid>
</DataTemplate>
</Controls:LiveTile.ItemTemplate>
</Controls:LiveTile>
<Image Source="{Binding ProfileImage}" Stretch="UniformToFill" HorizontalAlignment="Left" VerticalAlignment="Top" Height="270" Margin="165,46,0,0" Width="225"/>
<TextBlock Text="{Binding Name}" Margin="165,5,0,577" TextWrapping="Wrap" HorizontalAlignment="Left" Height="41" Width="252" FontSize="22" FontWeight="Bold"/>
<GridView x:Name="GridViewToFrinedsPhoto" Margin="461,0,0,0"
ItemsSource="{Binding Mode=TwoWay, Source={StaticResource groupedItemsViewSource}}"
ItemTemplate="{StaticResource MyPhotoItemTemplate}"
SelectionMode="Single"
IsItemClickEnabled="True"
IsSwipeEnabled="false" ItemClick="GridViewToFrinedsPhoto_ItemClick">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<Grid Margin="1,0,0,6">
<Button
x:Name="ColumnBtn"
AutomationProperties.Name="Group Title" AutomationProperties.LabeledBy="{Binding Title}"
Style="{StaticResource TextPrimaryButtonStyle}" Click="Button_Click_1">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Title}" Margin="3,-7,10,10" Style="{StaticResource GroupHeaderTextStyle}" />
<TextBlock Text="{StaticResource ChevronGlyph}" FontFamily="Segoe UI Symbol" Margin="0,-7,0,10" Style="{StaticResource GroupHeaderTextStyle}"/>
</StackPanel>
</Button>
</Grid>
</DataTemplate>
</GroupStyle.HeaderTemplate>
<GroupStyle.Panel>
<ItemsPanelTemplate>
<VariableSizedWrapGrid Orientation="Vertical" Margin="0,0,80,0"/>
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</GridView.GroupStyle>
</GridView>
</Grid>
</ScrollViewer>
</Grid>
</Grid>

How to make a grid in a DataTemplate for a ItemTemplate auto-size to ListBox width?

So I have the following DataTemplate for a ListBox.ItemTemplate:
<DataTemplate x:Key="Tweet">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Image
Grid.Column="0"
Source="{Binding ProfileImageURL}"
Width="50" Height="50"/>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock
Grid.Row="0"
FontSize="15"
FontWeight="Bold"
Text="{Binding User}"/>
<TextBlock
Grid.Row="1" TextWrapping="Wrap"
Text="{Binding Status}"/>
<DockPanel
Grid.Row="2">
<TextBlock
DockPanel.Dock="Left"
FontSize="10" TextWrapping="WrapWithOverflow"
Text="{Binding TimeAgo}" TextAlignment="Justify"/>
<TextBlock
DockPanel.Dock="Left"
FontSize="10" TextWrapping="Wrap"
Text="{Binding Source}"/>
</DockPanel>
</Grid>
</Grid>
</DataTemplate>
The problem is that it doesn't auto-size to the ListBox. The text gets clipped:
TwitBy preview
How to fix it?
Here's the listBox XAML definition:
<ListBox
x:Name="tweetsListBox"
Margin="3,0"
Grid.Row="1"
Background="{x:Null}" Grid.IsSharedSizeScope="True"
ItemsSource="{Binding}" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ItemTemplate="{DynamicResource Tweet}"/>
Any help would be appreciated.
Thanks
Try this:
<DataTemplate x:Key="Tweet">
<Grid Width="{Binding ElementName=tweetsListBox, Path=ActualWidth>">

Categories

Resources