Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to get value currently binded to textbox?
    text
    copied!<p>i need your advice, please:)</p> <p>I have a textbox inside a FlipView bound to title property, that shows current Title of a page. </p> <pre><code>&lt;TextBlock x:Name="jmeno" FontSize="26.667" FontWeight="Light" Text="{Binding Title}" TextWrapping="Wrap" /&gt; </code></pre> <p>And i have a media element showing a video.</p> <pre><code>&lt;MediaElement x:Name="mmedia" Source="Video/prvniVideo.mp4" Height="300" Grid.Row="1" KeyUp="mmedia_KeyUp" /&gt; </code></pre> <p>I would like to open different video on different pages and I am trying to accomplish it like this - read the actual display value of texblock and base on that decide, which video to open in media element.</p> <p>Something like this.</p> <pre><code> string AktualniStranka; AktualniStranka = jmeno.Text; if (AktualniStranka == "Exercise 1") { mmedia.Source = new Uri("ms-appx:/Video/prvniVideo.mp4", UriKind.RelativeOrAbsolute); mmedia.Play(); } else { mmedia.Source = new Uri("ms-appx:/Video/Gumm.mp4", UriKind.RelativeOrAbsolute); mmedia.Play(); } </code></pre> <p>But it is not working - I have tried to read just the text of the textblock and put it in another textblock and it is not working either, I have spent almost the whole day trying to make it work.. Please help guys:)</p> <p>Full XAML code:</p> <pre><code>&lt;common:LayoutAwarePage x:Name="pageRoot" x:Class="ContosoCookbook.ItemDetailPage" DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:ContosoCookbook" xmlns:data="using:ContosoCookbook.Data" xmlns:common="using:ContosoCookbook.Common" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"&gt; &lt;Page.Resources&gt; &lt;!-- Collection of items displayed by this page --&gt; &lt;Style x:Name="transportStyle" TargetType="Button"&gt; &lt;Setter Property="Height" Value="40" /&gt; &lt;Setter Property="Width" Value="75" /&gt; &lt;Setter Property="FontSize" Value="11" /&gt; &lt;/Style&gt; &lt;CollectionViewSource x:Name="itemsViewSource" Source="{Binding Items}" d:Source="{Binding AllGroups[0].Items, Source={d:DesignInstance Type=data:SampleDataSource, IsDesignTimeCreatable=True}}"/&gt; &lt;common:ListConverter x:Key="ListConverter" /&gt; &lt;Style x:Key="BragAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}"&gt; &lt;Setter Property="AutomationProperties.AutomationId" Value="BragAppBarButton"/&gt; &lt;Setter Property="AutomationProperties.Name" Value="Brag"/&gt; &lt;Setter Property="Content" Value="&amp;#xE170;"/&gt; &lt;/Style&gt; &lt;Style x:Key="ReminderAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}"&gt; &lt;Setter Property="AutomationProperties.AutomationId" Value="ReminderAppBarButton"/&gt; &lt;Setter Property="AutomationProperties.Name" Value="Reminder"/&gt; &lt;Setter Property="Content" Value="&amp;#xE121;"/&gt; &lt;/Style&gt; &lt;local:ProductLicenseDataSource x:Key="License" /&gt; &lt;common:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/&gt; &lt;/Page.Resources&gt; &lt;Page.BottomAppBar&gt; &lt;AppBar x:Name="PageAppBar" Padding="10,0,10,0"&gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="50*"/&gt; &lt;ColumnDefinition Width="50*"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;StackPanel x:Name="LeftCommands" Orientation="Horizontal" Grid.Column="0" HorizontalAlignment="Left"&gt; &lt;Button x:Name="BragButton" HorizontalAlignment="Left" Style="{StaticResource BragAppBarButtonStyle}" Click="OnBragButtonClicked" /&gt; &lt;Button x:Name="PinRecipeButton" HorizontalAlignment="Left" Style="{StaticResource PinAppBarButtonStyle}" Click="OnPinRecipeButtonClicked" /&gt; &lt;Button x:Name="ReminderButton" HorizontalAlignment="Left" Style="{StaticResource ReminderAppBarButtonStyle}" Click="OnReminderButtonClicked" /&gt; &lt;/StackPanel&gt; &lt;StackPanel x:Name="RightCommands" Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Right"&gt; &lt;/StackPanel&gt; &lt;/Grid&gt; &lt;/AppBar&gt; &lt;/Page.BottomAppBar&gt; &lt;!-- 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 --&gt; &lt;Grid Style="{StaticResource LayoutRootStyle}" DataContext="{Binding Group}" d:DataContext="{Binding AllGroups[0], Source={d:DesignInstance Type=data:SampleDataSource, IsDesignTimeCreatable=True}}"&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="140"/&gt; &lt;RowDefinition Height="*"/&gt; &lt;/Grid.RowDefinitions&gt; &lt;!-- The remainder of the page is one large FlipView that displays details for one item at a time, allowing the user to flip through all items in the chosen group --&gt; &lt;FlipView x:Name="flipView" AutomationProperties.AutomationId="ItemsFlipView" AutomationProperties.Name="Item Details" TabIndex="1" Grid.RowSpan="2" ItemsSource="{Binding Source={StaticResource itemsViewSource}}"&gt; &lt;FlipView.ItemContainerStyle&gt; &lt;Style TargetType="FlipViewItem"&gt; &lt;Setter Property="Margin" Value="0,137,0,0"/&gt; &lt;/Style&gt; &lt;/FlipView.ItemContainerStyle&gt; &lt;FlipView.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;UserControl Loaded="StartLayoutUpdates" Unloaded="StopLayoutUpdates"&gt; &lt;ScrollViewer x:Name="scrollViewer" Style="{StaticResource VerticalScrollViewerStyle}" Grid.Row="1"&gt; &lt;!-- Three-column grid for item-detail layout --&gt; &lt;Grid Margin="120,0,20,20"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="600" /&gt; &lt;ColumnDefinition Width="40" /&gt; &lt;ColumnDefinition /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;StackPanel Orientation="Vertical" Grid.Column="0"&gt; &lt;TextBlock x:Name="jmeno" FontSize="26.667" FontWeight="Light" Text="{Binding Title}" TextWrapping="Wrap" /&gt; &lt;/StackPanel&gt; &lt;StackPanel Orientation="Vertical" Grid.Column="4"&gt; &lt;TextBlock FontSize="26.667" FontWeight="Light" Text="Description" Margin="0,0,0,16"/&gt; &lt;TextBlock FontSize="26.667" FontWeight="Light" Text="{Binding ShortDesctiption}" TextWrapping="Wrap"/&gt; &lt;ScrollViewer Style="{StaticResource VerticalScrollViewerStyle}"&gt; &lt;Grid&gt; &lt;TextBlock FontSize="20" FontWeight="Light" Text="{Binding Directions}" TextWrapping="Wrap" Visibility="{Binding IsLicensed, Source={StaticResource License}, Converter={StaticResource BooleanToVisibilityConverter }}" /&gt; &lt;Button Width="225" Height="120" Background="#30ffffff" Click="OnPurchaseProduct" Visibility="{Binding IsTrial, Source={StaticResource License}, Converter={StaticResource BooleanToVisibilityConverter }}"&gt; &lt;Button.Content&gt; &lt;TextBlock Text="{Binding FormattedPrice, Source={StaticResource License}}" TextWrapping="Wrap" TextAlignment="Center" /&gt; &lt;/Button.Content&gt; &lt;/Button&gt; &lt;/Grid&gt; &lt;/ScrollViewer&gt; &lt;/StackPanel&gt; &lt;/Grid&gt; &lt;VisualStateManager.VisualStateGroups&gt; &lt;!-- Visual states reflect the app's view state inside the FlipView --&gt; &lt;VisualStateGroup x:Name="ApplicationViewStates"&gt; &lt;VisualState x:Name="FullScreenLandscape"/&gt; &lt;VisualState x:Name="Filled"/&gt; &lt;!-- Respect the narrower 100-pixel margin convention for portrait --&gt; &lt;VisualState x:Name="FullScreenPortrait"&gt; &lt;Storyboard&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="image" Storyboard.TargetProperty="MaxHeight"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="400"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;!-- When snapped, the content is reformatted and scrolls vertically --&gt; &lt;VisualState x:Name="Snapped"&gt; &lt;Storyboard&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="scrollViewer" Storyboard.TargetProperty="Style"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource VerticalScrollViewerStyle}"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="image" Storyboard.TargetProperty="MaxHeight"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="160"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;/VisualStateGroup&gt; &lt;/VisualStateManager.VisualStateGroups&gt; &lt;/ScrollViewer&gt; &lt;/UserControl&gt; &lt;/DataTemplate&gt; &lt;/FlipView.ItemTemplate&gt; &lt;/FlipView&gt; &lt;!-- MEDIA PANEL--&gt; &lt;StackPanel Orientation="Vertical" Grid.Row="1" &gt; &lt;Border BorderThickness="5" BorderBrush="White" Background="Black" HorizontalAlignment="Left" Margin="165,50,0,0" VerticalAlignment="Top"&gt; &lt;ContentControl x:Name="VideoContainer" Height="300" KeyUp="VideoContainer_KeyUp" &gt; &lt;MediaElement x:Name="mmedia" Source="Video/prvniVideo.mp4" Height="300" Grid.Row="1" KeyUp="mmedia_KeyUp" /&gt; &lt;/ContentControl&gt; &lt;/Border&gt; &lt;StackPanel Orientation="Horizontal" Margin="140,20,0,0"&gt; &lt;Button Name="btnPlay" Click="btnPlay_Click" Style="{StaticResource transportStyle}" Content="Play" /&gt; &lt;Button Name="btnPause" Click="btnPause_Click" Style="{StaticResource transportStyle}" Content="Pause" /&gt; &lt;Button Name="btnStop" Click="btnStop_Click" Style="{StaticResource transportStyle}" Content="Stop" /&gt; &lt;Button Name="btnReverse" Click="btnReverse_Click" Style="{StaticResource transportStyle}" Content="Rewind" /&gt; &lt;Button Name="btnForward" Click="btnForward_Click" Style="{StaticResource transportStyle}" Content="Forward" /&gt; &lt;Button Name="btnVolumeUp" Click="btnVolumeUp_Click" Style="{StaticResource transportStyle}" Content="-" /&gt; &lt;Button Name="btnVolumeDown" Click="btnVolumeDown_Click" Style="{StaticResource transportStyle}" Content="+" /&gt; &lt;Button Name="btnMute" Click="btnMute_Click" Style="{StaticResource transportStyle}" Content="Mute" /&gt; &lt;/StackPanel&gt; &lt;Button x:Name="btnFullScreenToggle" Click="btnFullScreenToggle_Click" Style="{StaticResource transportStyle}" Content="Full Screen ON" Margin="290,0,0,0" Width="302" /&gt; &lt;TextBlock x:Name="poser" FontSize="26.667" FontWeight="Light" Text="poser" TextWrapping="Wrap" /&gt; &lt;/StackPanel&gt; &lt;!-- FlipView used in portrait mode --&gt; &lt;FlipView x:Name="portraitFlipView" AutomationProperties.AutomationId="ItemsFlipView" AutomationProperties.Name="Item Details" Grid.Row="1" Margin="0,-3,20,0" ItemsSource="{Binding Source={StaticResource itemsViewSource}}" Visibility="Collapsed"&gt; &lt;FlipView.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;UserControl Loaded="StartLayoutUpdates" Unloaded="StopLayoutUpdates"&gt; &lt;ScrollViewer x:Name="scrollViewer" Style="{StaticResource VerticalScrollViewerStyle}" Grid.Row="1"&gt; &lt;!-- Vertical StackPanel for item-detail layout --&gt; &lt;StackPanel Orientation="Vertical" Margin="100,0,20,0"&gt; &lt;StackPanel Orientation="Vertical"&gt; &lt;TextBlock FontSize="26.667" FontWeight="Light" Text="{Binding Title}" TextWrapping="Wrap"/&gt; &lt;Image x:Name="image" Width="400" Margin="0,20,0,40" Stretch="Uniform" Source="{Binding Image}" HorizontalAlignment="Left"/&gt; &lt;/StackPanel&gt; &lt;StackPanel Orientation="Vertical"&gt; &lt;TextBlock FontSize="26.667" FontWeight="Light" Text="Ingredients" Margin="0,0,0,16"/&gt; &lt;TextBlock FontSize="20" FontWeight="Light" LineHeight="32.5" Text="{Binding Ingredients, Converter={StaticResource ListConverter}}" TextWrapping="Wrap" /&gt; &lt;/StackPanel&gt; &lt;StackPanel Orientation="Vertical"&gt; &lt;TextBlock FontSize="26.667" FontWeight="Light" Text="Directions" Margin="0,24,0,16"/&gt; &lt;ScrollViewer Style="{StaticResource VerticalScrollViewerStyle}"&gt; &lt;Grid&gt; &lt;TextBlock FontSize="20" FontWeight="Light" Text="{Binding Directions}" TextWrapping="Wrap" Visibility="{Binding IsLicensed, Source={StaticResource License}, Converter={StaticResource BooleanToVisibilityConverter }}" /&gt; &lt;Button Width="225" Height="120" Background="#30ffffff" Click="OnPurchaseProduct" Visibility="{Binding IsTrial, Source={StaticResource License}, Converter={StaticResource BooleanToVisibilityConverter }}"&gt; &lt;Button.Content&gt; &lt;TextBlock Text="{Binding FormattedPrice, Source={StaticResource License}}" TextWrapping="Wrap" TextAlignment="Center" /&gt; &lt;/Button.Content&gt; &lt;/Button&gt; &lt;/Grid&gt; &lt;/ScrollViewer&gt; &lt;/StackPanel&gt; &lt;/StackPanel&gt; &lt;/ScrollViewer&gt; &lt;/UserControl&gt; &lt;/DataTemplate&gt; &lt;/FlipView.ItemTemplate&gt; &lt;/FlipView&gt; &lt;FlipView x:Name="snappedFlipView" AutomationProperties.AutomationId="ItemsFlipView" AutomationProperties.Name="Item Details" Grid.Row="1" Margin="0,-3,0,0" ItemsSource="{Binding Source={StaticResource itemsViewSource}}" Visibility="Collapsed"&gt; &lt;FlipView.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;UserControl Loaded="StartLayoutUpdates" Unloaded="StopLayoutUpdates"&gt; &lt;ScrollViewer x:Name="scrollViewer" Style="{StaticResource VerticalScrollViewerStyle}" Grid.Row="1"&gt; &lt;!-- Vertical StackPanel for item-detail layout --&gt; &lt;StackPanel Orientation="Vertical" Margin="20,0,20,0"&gt; &lt;StackPanel Orientation="Vertical"&gt; &lt;TextBlock FontSize="20" FontWeight="Light" Text="{Binding Title}" TextWrapping="Wrap"/&gt; &lt;Image x:Name="image" Width="260" Margin="0,12,0,40" Stretch="Uniform" Source="{Binding Image}" HorizontalAlignment="Left"/&gt; &lt;/StackPanel&gt; &lt;StackPanel Orientation="Vertical"&gt; &lt;TextBlock FontSize="20" FontWeight="Light" Text="Ingredients" Margin="0,0,0,16"/&gt; &lt;TextBlock FontSize="16" FontWeight="Light" TextWrapping="Wrap" Text="{Binding Ingredients, Converter={StaticResource ListConverter}}" /&gt; &lt;/StackPanel&gt; &lt;/StackPanel&gt; &lt;/ScrollViewer&gt; &lt;/UserControl&gt; &lt;/DataTemplate&gt; &lt;/FlipView.ItemTemplate&gt; &lt;/FlipView&gt; &lt;!-- Back button and page title --&gt; &lt;Grid HorizontalAlignment="Left" &gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="Auto"/&gt; &lt;ColumnDefinition Width="*"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/&gt; &lt;TextBlock x:Name="pageTitle" Text="{Binding Title}" Style="{StaticResource PageHeaderTextStyle}" Grid.Column="1" IsHitTestVisible="false"/&gt; &lt;Button Name="btnFullScreenOff" Click="btnFullScreenToggle_Click" Style="{StaticResource transportStyle}" Content="Full Screen OFF" HorizontalAlignment="Right" Grid.Column="1" Margin="0,56,495,36" RenderTransformOrigin="-9.161,0.266" Height="48" Width="106" Visibility="Collapsed" /&gt; &lt;/Grid&gt; &lt;VisualStateManager.VisualStateGroups&gt; &lt;!-- Visual states reflect the application's view state --&gt; &lt;VisualStateGroup x:Name="ApplicationViewStates"&gt; &lt;VisualState x:Name="FullScreenLandscape"/&gt; &lt;VisualState x:Name="Filled"/&gt; &lt;!-- The back button respects the narrower 100-pixel margin convention for portrait --&gt; &lt;VisualState x:Name="FullScreenPortrait"&gt; &lt;Storyboard&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="flipView" Storyboard.TargetProperty="Visibility"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="portraitFlipView" Storyboard.TargetProperty="Visibility"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;!-- The back button and title have different styles when snapped --&gt; &lt;VisualState x:Name="Snapped"&gt; &lt;Storyboard&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="flipView" Storyboard.TargetProperty="Visibility"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="snappedFlipView" Storyboard.TargetProperty="Visibility"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;/VisualStateGroup&gt; &lt;/VisualStateManager.VisualStateGroups&gt; &lt;/Grid&gt; </code></pre> <p></p> <p>Full C# code:</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload