how block screen while running a task in Windows Phone RT / 10? - windows

I am creating a application for Windows 10, and I want know, how do I lock the screen while performing a task after I clicked in button?
private void UxBtnProximo_Click(object sender, RoutedEventArgs e)
{
if (dia > 0)
{
dia -= 1;
DefinePapelParede();
}
if(dia == 0)
{
UxBtnProximo.Visibility = Visibility.Collapsed;
}
else
{
UxBtnProximo.Visibility = Visibility.Visible;
}
}
Datail, the button is in a frame and not in screen
<SplitView.Content>
<Frame x:Name="UxFrmPrincipal">
<Frame.ContentTransitions>
<TransitionCollection>
<NavigationThemeTransition>
<NavigationThemeTransition.DefaultNavigationTransitionInfo>
<EntranceNavigationTransitionInfo/>
</NavigationThemeTransition.DefaultNavigationTransitionInfo>
</NavigationThemeTransition>
</TransitionCollection>
</Frame.ContentTransitions>
</Frame>
</SplitView.Content>
and here is page into this frame
<Grid x:Name="PrincipalGrid">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="250"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="100"></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0">
</StackPanel>
<StackPanel Grid.Row="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="100"></RowDefinition>
</Grid.RowDefinitions>
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Row="0" Grid.Column="0">
<Button x:Name="UxBtnAnterior" FontSize="60" FontFamily="Segoe MDL2 Assets" Content="" Foreground="White" Background="Transparent"></Button>
</StackPanel>
<StackPanel HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Row="0" Grid.Column="2">
<Button x:Name="UxBtnProximo" FontFamily="Segoe MDL2 Assets" FontSize="60" Content="" Foreground="White" Background="Transparent"></Button>
</StackPanel>
</Grid>
</StackPanel>
<StackPanel Grid.Row="2" Background="#66000000" VerticalAlignment="Center" HorizontalAlignment="Center">
<Button x:Name="UxBtnSetWallPaper" FontSize="50" Foreground="#FFFFFF" Content="Aplicar"></Button>
</StackPanel>
<Popup IsOpen="True" x:Name="UxPopCarregando">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" UseLayoutRounding="True">
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch" UseLayoutRounding="True">
<ProgressRing Height="200" Width="200" UseLayoutRounding="True" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Gray">
</ProgressRing>
</StackPanel>
</Grid>
</Popup>
</Grid>
I Tryied popup, but not work, I may have used wrong. help!

This can easily be accomplished with a simple overlay on your page
<Page>
<Grid>
<!-- regular content here -->
<Grid x:Name="BlockIt" Visibility="Collapsed" Background="#55ffffff"/>
</Page>
When you want to stop user interaction, change the visibility of the BlockIt grid
BlockIt.Visibility = Visibility.Visible;

Related

ListView Item doesn't expand-collapse height in Xamarin Forms

I have a List View. In ListView I have ListViewCell. ListViewCell have expand-Collapse functionality. There are few problems in expand collapse behaviours.
1- If I expand first item, it works fine. But If I expand second item first and expand first item, it first item goes behind. See Case-1 in screen shot.
2- If I click on list view item, it show in gray color for a second. I want to stop this. It should not change and color when user click on any cell. Case-2
3- If I expand first item and collapse it again. It collapse but it keep white space between second and first item.
I have noticed this behavior. Above issue resolve if I scroll down and up. Well, in ideal case, user doesn't scroll up and down after every operation :D
Note: I have Entry, DatePicker and Buttons in ListViewCell. User must be able to input in it.
Here is my code. I have also attached screen shot. Please suggest
Main Page List View
<ListView x:Name="WorkHistoryListView"
ItemsSource="{Binding WorkHistoryList}"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
SeparatorVisibility="None"
ItemTapped="OnListViewItemTapped"
Margin="10"
HasUnevenRows = "true"
IsPullToRefreshEnabled="False">
<ListView.ItemTemplate>
<DataTemplate>
<localview:WorkHistoryViewCell />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
WorkHistoryViewCell.xaml
<StackLayout Margin="0" Padding="0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<!-- Blue heading-->
<StackLayout Margin="0" Padding="0" Grid.Row="0" BackgroundColor="#367fa9">
<Grid HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
Padding="15" RowSpacing="10" Margin="0" BackgroundColor="Transparent">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Label Text="{Binding Name}" HorizontalOptions="Center" Grid.Column="0" Grid.Row="0"/>
<Label Text="{Binding Date}" HorizontalOptions="Center" Grid.Column="1" Grid.Row="1"/>
<Label Text="+" HorizontalOptions="End" VerticalOptions="Center" Grid.Column="2" x:Name="LabelCollapse" Grid.Row="0" Grid.RowSpan="2" FontFamily="Roboto">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="LabelOpenCommand"/>
</Label.GestureRecognizers>
</Label>
</Grid>
</StackLayout>
<StackLayout Margin="0" Padding="0" Grid.Row="1" x:Name="FrameVisible">
<Frame Margin="0" Padding="0" HorizontalOptions="FillAndExpand" BackgroundColor="White" OutlineColor="Gray">
<StackLayout Margin="0" VerticalOptions="Fill" Padding="20" IsVisible="{Binding IsWeekly}">
<Grid>
<Grid.Resources>
<ResourceDictionary>
<local:InvertBooleanConverter x:Key="invertBooleanConverter" />
<Style x:Key="LabelStyle" TargetType="Label">
<Setter Property="FontSize" Value="15"/>
<Setter Property="FontFamily" Value="Roboto"/>
<Setter Property="TextColor" Value="White"/>
</Style>
</ResourceDictionary>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="125"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
</Grid.RowDefinitions>
<Image Source="EditLog.png" Grid.Column="1" Grid.Row="0" HorizontalOptions="End" VerticalOptions="Center"
HeightRequest="24">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OnImageViewItemTapped"/>
</Image.GestureRecognizers>
</Image>
<Label Text="Date" Grid.Column="0" Grid.Row="0" Style="{StaticResource LabelStyle}"
TextColor="Black" FontFamily="Roboto" Margin="0" />
<local:ExtendedDatePicker TextColor="LightGray" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1"
IsEnabled="False" Date="{Binding Date}" BackgroundColor="White">
<DatePicker.Format>dd/MM/yyyy</DatePicker.Format>
</local:ExtendedDatePicker>
<Label Text="Pay" Grid.Column="0" Grid.Row="2" Style="{StaticResource LabelStyle}"
TextColor="Black" FontFamily="Roboto" Margin="0,10,0,0" />
<local:CustomEntry Grid.Column="0" Grid.Row="3" Margin="0,10,0,0" WidthRequest="150" Text="{Binding Pay}"
Style="{StaticResource LabelStyle}" TextColor="Black" HorizontalOptions="EndAndExpand" VerticalOptions="FillAndExpand"/>
<Button Text="Submit" BorderRadius="18" TextColor="White" Command="{Binding SubmitWeeklyCommand}" Grid.Column="0" Grid.Row="4" FontFamily="Roboto"/>
</Grid>
</StackLayout>
</Frame>
</StackLayout>
</Grid>
</StackLayout>
WorkHistoryViewCell.xaml.cs //Command to expand collapse
private void LabelOpenCommand(object sender,TappedEventArgs e)
{
if (LabelCollapse.Text == "+")
{
FrameVisible.IsVisible = false;
LabelCollapse.Text = "-";
FrameVisible.IsVisible = true;
}
else
{
FrameVisible.IsVisible = true;
LabelCollapse.Text = "+";
FrameVisible.IsVisible = false;
}
}
Screenshot
It happens 'cause the cell's height is calculated only on the first rendering. After that, the changes affect just the inner layout view.
Try call ForceUpdateSize(); at the end of your current TappedCommand's logic. It'll force the entire cell to recalculate its bounds.
The code should look like:
private void LabelOpenCommand(object sender,TappedEventArgs e)
{
if (LabelCollapse.Text == "+")
{
FrameVisible.IsVisible = false;
LabelCollapse.Text = "-";
FrameVisible.IsVisible = true;
}
else
{
FrameVisible.IsVisible = true;
LabelCollapse.Text = "+";
FrameVisible.IsVisible = false;
}
ForceUpdateSize
}
I hope it helps.

How to implement <Grid> in Universal Windows Platform App?

How to use Gird in Windows Apps?
I want to create a Login form. I have used grid and used but the Rows are not aligned properly, How can I do that?
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="67*"/>
<ColumnDefinition Width="293*"/>
</Grid.ColumnDefinitions>
<StackPanel>
<TextBlock Text="Name" Height="32" Margin="0,0,0.333,0" ></TextBlock>
<TextBlock Text="Last Name" Height="30" Margin="0,0,0.333,0" ></TextBlock>
<TextBlock Text="Address"></TextBlock>
</StackPanel>
<StackPanel Grid.Column="1">
<TextBox></TextBox>
<TextBox></TextBox>
<TextBox></TextBox>
</StackPanel>
</Grid>
You should define the rows and columns in Grid.
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="67*"/>
<ColumnDefinition Width="293*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="45"></RowDefinition>
<RowDefinition Height="45"></RowDefinition>
<RowDefinition Height="45"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Text="Name" Grid.Column="0" Grid.Row="0" VerticalAlignment="Center"></TextBlock>
<TextBlock Text="Last Name" Grid.Column="0" Grid.Row="1" VerticalAlignment="Center"></TextBlock>
<TextBlock Text="Address" Grid.Column="0" Grid.Row="2" VerticalAlignment="Center"></TextBlock>
<TextBox Grid.Column="1" Grid.Row="0" Height="30"></TextBox>
<TextBox Grid.Column="1" Grid.Row="1" Height="30"></TextBox>
<TextBox Grid.Column="1" Grid.Row="2" Height="30"></TextBox>
</Grid>

phone:WebBrowser how we can set Auto Height and Width?

<StackPanel Orientation="Vertical">
<TextBlock x:Name="articleDate" Foreground="Black" FontSize="20"
Text="Timefzdsaf" />
<Image x:Name="image" Stretch="Uniform" />
<StackPanel Orientation="Vertical">
<phone:WebBrowser Name="webBrowser1"
IsScriptEnabled="False" Background="White"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center"
></phone:WebBrowser>
</StackPanel>
phone:WebBrowser will not show in my page(if am not giving Height and Width i want it should take automatically). can any one help me to show html in phone WebBrowser?
Don't use the StackPanel. Try Grid with RowDefinitions. For WebBrowser set it to "*"
From your code (added Source just to demonstrate):
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock x:Name="articleDate"
Foreground="Black"
FontSize="20"
Text="Timefzdsaf" />
<Image x:Name="image"
Grid.Row="1"
Stretch="Uniform" />
<phone:WebBrowser Name="webBrowser1"
Source="http://msdn.microsoft.com/en-US/"
IsScriptEnabled="False"
Grid.Row="2"
Background="White"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center">
</phone:WebBrowser>
</Grid>

AUTOCOMPLETE SUGGESTIONS APPEARS ON TOP OF TEXT BOX -WINDOWS PHONE

I am using auto complete textbox from windows phone toolkit.I need the list of suggestions below my textbox but it shows up above the text box .How do I make the suggestions appear below the text box..Here is my XAML.
<Grid Margin="0,336,0,189" x:Name="editrow" Visibility="Visible">
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="220" ></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
</Grid.ColumnDefinitions>
<toolkit:AutoCompleteBox x:Name="newname" FilterMode="StartsWith" IsTextCompletionEnabled="True" Foreground="White" Background="#53000000" BorderThickness="0" Grid.Column="0" Grid.Row="0" Margin="10,0,0,0" IsDropDownOpen="True" RenderTransformOrigin="0,0">
<toolkit:AutoCompleteBox.ItemTemplate>
<DataTemplate>
<StackPanel Background="Gray" Orientation="Horizontal">
<TextBlock Text="{Binding }"/>
</StackPanel>
</DataTemplate>
</toolkit:AutoCompleteBox.ItemTemplate>
</toolkit:AutoCompleteBox>
<TextBox x:Name="rowquantity" Foreground="White" Background="#53000000" BorderThickness="0" Grid.Column="1" Grid.Row="0" InputScope="Number"></TextBox>
<toolkit:ListPicker Grid.Row="0" x:Name="units" Foreground="White" BorderThickness="0" Background="#53000000" Grid.Column="2" ExpansionMode="FullScreenOnly" Margin="12,5,0,14" >
<toolkit:ListPicker.FullModeItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0 0 0 0">
<TextBlock Text="{Binding}"
FontSize="32" LineHeight="1"/>
</StackPanel>
</DataTemplate>
</toolkit:ListPicker.FullModeItemTemplate>
</toolkit:ListPicker>
<Button Content="Add" BorderBrush="#53000000" Foreground="#53000000" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Top" Height="74" Click="Button_Click" Margin="0,0,3,0" Width="158"/>
</Grid>
The location of the popup is determined based on the available size. If there's more space above the AutoCompleteTextBox, it will pop up. You can see this in the popuphelper.cs source file where the code arranges the popup.
There really isn't an option to override the behavior.

Windows Phone 7 - Keyboard showing up for now reason

So I have a listbox with a template in which I bind an ObservableCollection of objects called "TotalDebits".
I have two way to delete the items:
One by one through a context menu
By range through a delete button and by fetching the checked objects.
This works:
private void Delete_Click(object sender, RoutedEventArgs e)
{
DeleteDebit((DirectDebit)(((MenuItem)sender).DataContext));
}
private void DeleteDebit(DirectDebit ddb)
{
TotalDebits.Remove(ddb);
}
private void delete_Click(object sender, EventArgs e)
{
DeleteDebitList();
}
private void DeleteDebitList()
{
try
{
foreach (var ddb in TotalDebits.ToList())
if (ddb.IsChecked)
TotalDebits.Remove(ddb);
}
catch
{
}
}
In both case, the items are properly deleted, the problem is, in the second case, the keyboard is showing up right after the items are deleted, for absolutely no reason.. Of course I can hide it right after by focusing on the list but it looks ugly and I wish I could find a way to prevent this issue from happening.
Edit:
You'll find hereunder the xaml of the page:
<controls:PivotItem Header="Direct Debit" >
<Grid>
<Grid.Resources>
<Storyboard x:Name="ListboxSizeIncrease">
<DoubleAnimation Storyboard.TargetName="DebitList" Storyboard.TargetProperty="Height"
From="475" To="380" Duration="0:0:.5"/>
</Storyboard>
<Storyboard x:Name="ListboxSizeDecrease">
<DoubleAnimation Storyboard.TargetName="DebitList" Storyboard.TargetProperty="Height"
From="380" To="475" Duration="0:0:.5"/>
</Storyboard>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ListBox Grid.Row="0" x:Name="DebitList" Height="475" Margin="10,5,10,0" Tap="ListBox_Tap" ItemsSource="{Binding TotalDebits}" VerticalAlignment="Top" ItemContainerStyle="{StaticResource CustomListBoxItem}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,2,0,2">
<Grid Margin="5,5,5,5" HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60" />
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<CheckBox x:Name="CheckItem" Grid.Column="0" IsChecked="{Binding IsChecked}" Checked="CheckItem_Checked" Unchecked="CheckItem_Unchecked" />
<TextBlock x:Name="DescriptionBlock" FontSize="24" Grid.Column ="1" Text="{Binding Description}" HorizontalAlignment="Left" VerticalAlignment="Center">
</TextBlock>
<TextBlock FontSize="24" Grid.Column ="2" Text="{Binding Amount}" TextAlignment="Right" HorizontalAlignment="Right" VerticalAlignment="Center"/>
</Grid>
<toolkit:ContextMenuService.ContextMenu>
<toolkit:ContextMenu Name="ContextMenu" IsZoomEnabled="False">
<toolkit:MenuItem Name="Edit" Header="Edit" Click="Edit_Click"/>
<toolkit:MenuItem Name="Delete" Header="Delete" Click="Delete_Click"/>
</toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Border Margin="12,5,12,5" Grid.Row="1" Background="LightGray"/>
<Grid Grid.Row="1" Margin="14,8,14,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="TOTAL DIRECT DEBIT" FontSize="28" FontWeight="Bold" Foreground="DarkSlateGray"/>
<TextBlock Grid.Column="1" x:Name="TotalBlock" Text="{Binding TotalValue}" FontSize="28" FontWeight="Bold" Foreground="DarkSlateGray"/>
</Grid>
<Grid Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Border Margin="12,5,12,5" Background="LightGray">
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Grid.Column="0">
<TextBlock Margin="10,0,0,0" Text="Description" FontSize="20" Foreground="DarkSlateGray"/>
<TextBox x:Name="DescriptionBox" FontSize="15" />
</StackPanel>
<Grid Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Grid.Column="0">
<TextBlock Margin="0,0,0,0" Text="Amount" Foreground="DarkSlateGray"/>
<TextBox x:Name="AmountBox" FontSize="15" />
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="1">
<TextBlock Margin="10,0,0,0" Text="." Foreground="DarkSlateGray"/>
<TextBox x:Name="DecimalBox" Width="60" FontSize="15" MaxLength="2"/>
</StackPanel>
</Grid>
</Grid>
</Border>
</Grid>
</Grid>
</controls:PivotItem>

Resources