WPF Scrollviewer on touch screen tablet - wpf

I'm writing a WPF application that is going to run on a full windows 8 touchscreen tablet (not RT).
However touch scrolling doesn't seem to be working. So I'm wondering if it's something I'm doing wrong or if it's even possible?
So, I have a WPF window with a scrollviewer. Within that scrollviewer I have a StackPanel which has loads of textblocks within it. See below:
<ScrollViewer>
<StackPanel>
<TextBlock Text="Row 1" />
<TextBlock Text="Row 2" />
<TextBlock Text="Row 3" />
<TextBlock Text="Row 4" />
<TextBlock Text="Row 5" />
<TextBlock Text="Row 6" />
....
<TextBlock Text="Row 50" />
</StackPanel>
</ScrollViewer>
Now using the touchscreen I try to scroll the contents but it doesn't move. I can only scroll the contents using side scollbar which is not how I want this to work. Is it possible to get touch scrolling working with WPF? I'd also want to do the same with the grid.
Thanks in advance.
I'm using Visual Studio/Blend 2012.

You can enable scrolling with the PanningMode property like this:
<ScrollViewer PanningMode="Both"></ScrollViewer>.
See: MSDN
Mouse support
If you want to implement this behavior with the mouse, please read this article.

Related

Checkbox in my windows 8.1 app won't activate in emulator

I know this is going to sound really stupid but is there anything I'm missing because I have a simple page in my windows 8.1 phone app with a checkbox and a button. I can click on the button just fine in the emulator but I can't get the checkbox to check or uncheck at all. I feel really stupid for not being able to do something this simple. Am I missing something here?
<Grid>
<TextBlock Name="lblTermsofAgreement"/>
<CheckBox Name="chkAcceptTerms" Checked="chkAcceptTerms_Checked" Click="chkAcceptTerms_Click" Unchecked="chkAcceptTerms_Unchecked" HorizontalAlignment="Center" Content="I accept the terms of agreement" VerticalAlignment="Center" IsEnabled="True"></CheckBox>
<TextBlock Name="lblTermsError" FontFamily="Red" Text="" />
<Button Name="btnAccept" Click="btnAccept_Click" Content="Accept" HorizontalAlignment="Center" VerticalAlignment="Bottom"></Button>
</Grid>
All the controls are in row 0 column 0 for the grid so there was a control on top of it preventing it from getting checked. I would either add rows to the grid and set there rows or put the controls in a stack panel.
<Grid>
<StackPanel>
<TextBlock Name="lblTermsofAgreement"/>
<CheckBox Name="chkAcceptTerms" HorizontalAlignment="Center" Content="I accept the terms of agreement" VerticalAlignment="Center" IsEnabled="True"></CheckBox>
<TextBlock Name="lblTermsError" FontFamily="Red" Text="" />
<Button Name="btnAccept" Content="Accept" HorizontalAlignment="Center" VerticalAlignment="Bottom"></Button>
</StackPanel>
</Grid>

How to avoid sizing grip overlap in Window

I made a WPF Window containing StatusBar with StatusBarItem and ProgressBar.
The Window has a property ResizeMode set to CanResizeWithGrip.
It shows the sizing grip properly, but it overlaps elements underneath:
How can I avoid this overlap? I can set right margin to the progress bar, but how large? I don't want to use any magic numbers or hardcoded values. It would be also nice to have this resolved purely in XAML.
You can change style for "Window" considering all wishes.
http://msdn.microsoft.com/en-us/library/aa969824(v=vs.110).aspx
or https://stackoverflow.com/a/8278917/3492412
Or can do something like this
<StatusBar VerticalAlignment="Bottom">
<StatusBarItem x:Name="statusbar" Background="Gray" HorizontalContentAlignment="Stretch">
<DockPanel>
<ResizeGrip DockPanel.Dock="Right" Visibility="Hidden" />
<ProgressBar Background="red" Height="20" Value="50" />
</DockPanel>
</StatusBarItem>
</StatusBar>

Windows phone layer

How can I create the effect similar to Windows Phone's MessageBox, where the message gets displayed on a new layer with transparent background, so that the windows becomes modal? My layout is created out of Grid, so I do not know how to add any content over it. Please help.
It's easy to overlay one set of content with another in WPF. Try changing the visibility of the border below, for a simple message box effect. You would of course bind Visibility to your view model, or set it in code behind.
<Grid>
<Grid>
<!-- All your layout here -->
</Grid>
<Border Height="100" Width="100" Background="Azure" Visibility="Hidden">
<TextBlock Text="Hi there" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</Grid>

Silverlight 4 tab order problem?

I’d like to find out if I am missing something in my XAML code related to the tabbing. In my case, I need to click twice to be able to advance to the next control in the tab order. It will be great to find out the proper way applying tabbing in Silverlight 4. Below is the code I use for tabbing. Thank you in advance!
<StackPanel x:Name="sp" Grid.Column="0" >
<TextBlock x:Name="txtO" Style="{StaticResource AVV_TitleStyleBlue}" Text="Text" />
<HyperlinkButton x:Name="hl1" Style="{StaticResource AVV_HyperlinkButtonStyle}" Content="test 1" IsTabStop="True" TabIndex="11" />
<HyperlinkButton x:Name="hl2" Style="{StaticResource AVV_HyperlinkButtonStyle}" Content="test 2" IsTabStop="True" TabIndex="12"/>
<HyperlinkButton x:Name="hl3" Style="{StaticResource AVV_HyperlinkButtonStyle}" Content="test 3" IsTabStop="True" TabIndex="13" />
<HyperlinkButton x:Name="hl4" Style="{StaticResource AVV_HyperlinkButtonStyle}" Content="test 4" IsTabStop="True" TabIndex="14" />
</StackPanel>
You might have the issue where a sub control is also getting the tab, i guess that since you need to tab twice. On the first tab is most likely taking you to a hidden control, The second tab then takes you to the control you want. To fix this you need to find out what control the focus is going to when you hit Tab. You can do that by using the Focus Manager's get Focused Component method; you put that in a place just after you hit tab, you may need a small delay before getting the control. Then you set a break point in VS, and get the info about that control. Once found you set its IsTabStop Property to false. If you are using a third party control, you will need to change its template maybe using expression blend.

Creating Popup programmatically in WP7

How to create the popup in program? e.g. I need to rename the file in phone App. How to do this by using popup in wp7?
Add a Popup element to your XAML and define the content using regular elements (as you would any other Page or UserControl. Set the Popup.IsOpen property to true to show the Popup and false to close the Popup. The following XAML shows an example that I use for showing in-application "toast" notifications with the Silverlight Windows Phone Toolkit
<Popup x:Name="_toast">
<Grid x:Name="_toastContainer"
VerticalAlignment="Bottom"
Width="{Binding ActualWidth, ElementName=LayoutRoot}">
<StackPanel Margin="14,10">
<TextBlock Text="{Binding Title}"
HorizontalAlignment="Stretch"
TextWrapping="Wrap" />
<TextBlock Text="{Binding Content}"
HorizontalAlignment="Stretch"
TextWrapping="Wrap" />
</StackPanel>
</Grid>
</Popup>
Take a look at the Input Prompt control in the Coding4Fun Windows Phone Toolkit

Resources