Hub Tiles animation "semi expanded" broken - silverlight

I have an issue with the Windows Phone toolkit's hub tile.
All my hub tiles disappear when the animation state change to "semi expanded" (The one where half the icon + the text is visible). After a while the will change their animation state to different one and thetext or the right images show up as you expect them to.
It works in the emulator but not on my Lumia 800 and in the XAML preview of VS. Programming for WP 7.5 with VS 2010 on Win7 x64.
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Grid HorizontalAlignment="Stretch" Margin="0,0,0,12">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<toolkit:HubTile
Grid.Row="1"
Grid.Column="0"
Margin="12,12,0,0"
Title="Brew 
House"
Source=""
Tap="HubTile_Tap"
Name="BrewHouseTile">
</toolkit:HubTile>
<toolkit:HubTile
Grid.Row="1"
Grid.Column="1"
Margin="12,12,0,0"
Title="Hops"
Source="/BrewingApp;component/Images/icon_hops_big.png"
Tap="HubTile_Tap"
Name="HopsTile" />
<toolkit:HubTile
Grid.Row="2"
Grid.Column="0"
Margin="12,12,0,0"
Title="Convert 
Units"
Tap="HubTile_Tap"
Source="/BrewingApp;component/Images/icon_scales_big.png"
Name="ConvertersTile" />
... more Hub Tiles
</Grid>
</Grid>

This actually a bug in the Windows Phone toolkit. Upon resizing of the Hub Tiles the width and height get calculated again. This calculation uses a Float.TryParse() method that relies on a CultureSetting. However, when not set to EN-US this break. There is an issue on Codeplex with a quickfix:
http://phone.codeplex.com/workitem/10602

This has exactly happened to me.
To resolve the bug:
You need to download the toolkit sources from here: http://phone.codeplex.com/SourceControl/changeset/view/80797#
Modify the HubTileConverters.cs as it´s said in http://phone.codeplex.com/workitem/10602
And then compile. The dll file will be in the Bin ->Debug or Bin->Release depending if you compiled in debug or device mode.
You use this new dll fixed and works perfectly.

Related

How to display images larger than 33k in a Image control?

I try to display really huge(4k * 120k or larger like 4k * 300k) images in an Image control in WPF.
Although it's only displaying the first part of the image correctly, around 33k row, the display becomes garbage(black in this case, but it's dependent on the image).
The XAML code for the image control.
View is a BitmapImage and setting the DecodePixelHeight won't help either.
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<ScrollViewer
Grid.Row="0"
Grid.Column="0"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto" >
<Image VerticalAlignment="Top" HorizontalAlignment="Left" x:Name="viewImage"
Source="{Binding View}" />
</ScrollViewer>
Am i doing something wrong, or there is a limitation in the size of the Image control?
As Clemens mentioned, BitmapSource has a 2^16 limit in dimensions.
link

Appium can't locate collapsed element

I'm trying to access the Type property of the custom prompt dialog from an automation test. So the element for the Type (text box or text block) is collapsed because no one needs to see it, I just need it for logical processing on automation side.
I don't understand why it can't be located despite being available in the tree. or is there another why to get such access?
XAML:
<controls:PromptDialog ...
AutomationProperties.AutomationId="PromptView"
d:DataContext="{d:DesignInstance Type=viewModels:PromptViewModel}">
<Grid Margin="{StaticResource MarginThickness}">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="{StaticResource Gutter}" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!--Prompt-->
<Grid Grid.Row="0"
Visibility="{Binding IsShowingPrompt, Converter={StaticResource BooleanToVisibilityConverter}}">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="4" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="{StaticResource Gutter}" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<!--Image-->
<ContentControl Grid.Row="0"
Grid.Column="0"
Content="{Binding}">
<ContentControl.Resources>
<DataTemplate DataType="{x:Type viewModels:PromptViewModel}">
<Image Name="Image" />
//displaying image per type
</ContentControl.Resources>
</ContentControl>
<ScrollViewer Grid.Row="0"
Grid.Column="2"
Focusable="False"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled"
MaxHeight="400">
<StackPanel>
<TextBlock behaviors:TextBoxHyperlinkBehavior.Text="{Binding Text}"
TextWrapping="Wrap"
Focusable="False"
VerticalAlignment="Center"
HorizontalAlignment="Left"
FontFamily="{Binding Font.Name}"
Foreground="{Binding FontColor}"
AutomationProperties.AutomationId="PrompView_Text" />
<TextBox Visibility="Collapsed"
Text="{Binding Type}"
AutomationProperties.AutomationId="PromptView_Type" />
</StackPanel>
</ScrollViewer>
<!--Commands-->
<UniformGrid Grid.Row="2" Rows="1" HorizontalAlignment="Right">
// buttons
</UniformGrid>
</Grid>
</controls:PromptDialog>
Appium:
public IVisualElement Type => _appiumSession.CreateVisualAppiumElement("PromptView_Type");
Or
public AppiumWebElement Type => _appiumSession.FindElementByAccessibilityId("PromptView_Type");
WPF Snoop:
Error:
OpenQA.Selenium.WebDriverTimeoutException : Timed out after 10 seconds
---- OpenQA.Selenium.WebDriverException : An element could not be located on the page using the given search parameters.
Any pointers are highly appreciated,
thanks
There were several times when I used Snoop and it found more elements/attributes that Appium can access.
That is why now I am using Accessibility Insights for Windows. Of course you can use inspect.exe, but Accessibility Insights for Windows is the recommended from Microsoft. You can also try WinAppDriver UI Recorder that is generating XPaths.
If your element is not present in Accessibility Insights for Windows Appium will not be able to locate it.
According to documentation:
https://learn.microsoft.com/en-us/dotnet/api/system.windows.visibility?view=net-5.0
Collapsed elements are not rendered and NOT in layout.
Why not to use Visibility.Hidden instead, or Visibility.Visible with height of 0px.
I don't know anything about Appium, but the problem could be solve with .net automation api very easily.
// Must find top window of app first or could cause overflow easily.
var topWindow = AutomationElement.RootElement.FindFirst(TreeScope.Children,
new PropertyCondition(AutomationElement.AutomationIdProperty, "Id of top window"));
// Find out your target element if it's in visual tree, whatever it's collapsed or not.
// You can also Find out another element in the middle first to reduce the search work.
var target = topWindow.FindFirst(TreeScope.Descendants,
new PropertyCondition(AutomationElement.AutomationIdProperty, "PromptView_Type"));
// retrieve the value.
var val = ((ValuePattern)target.GetCurrentPattern(ValuePattern.Pattern)).Current.Value;
You have to add reference to UIAutomationClient.dll and UIAutomationType.dll to make this code work.
Update for .net core app
For .net core(3.0, 3.1, 5.0), there's a huge difference about how an automation peer answer inquiry than .net framework app. Automation peer will not answer inquiry if it's offscreen(control's visibility had been set to collapsed or hidden) unless inquiry was targeting raw view. So we have to force inquiry target to make it works.
var topWindow = AutomationElement.RootElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.AutomationIdProperty, "Id of top window"));
AutomationElement target = null;
var cr = new CacheRequest()
{
TreeFilter = Automation.RawViewCondition,
};
using (cr.Activate())
{
target = topWindow.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "PromptView_Type"));
}

Prevent focus/tabbing into non visible element in UI

For example, I have Grid with two rows and GridSplitter between them. When one the rows is not visible in UI (eg. splitter is all the way on top; real case scenario is more complicated with nested controls) elements are still reachable via tab key - I would like to prevent that.
I am aware of IsVisible property of FrameworkElement (is true even for such elements) and/or IsEnabled/IsTabStop and KeyboardNavigation class in general, but none of them solves my problem. My elements are usable etc., just not currently visible in UI because of grid splitter. Basically only framework elements which can be reached by mouse should also participate in tab key functionality.
Simplest case when it can be reproduced is following content of main window (move splitter to upper most position).
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="10"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBox Grid.Row="0" KeyboardNavigation.TabNavigation="Once"/>
<GridSplitter Height="10" Grid.Row="1" KeyboardNavigation.TabNavigation="Once" HorizontalAlignment="Stretch"/>
<Grid Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBox x:Name="PART_Problem" Grid.Row="0" KeyboardNavigation.TabNavigation="Once"/>
<TextBox Grid.Row="1" KeyboardNavigation.TabNavigation="Once"/>
</Grid>
</Grid>
Result should be that non-visible elements should be skipped and next visible element should be focused instead. This functionality should be compatible with KeyboardNavigation.ControlTabNavigation.
Edit 1: changed sample a little in order to show, that PART_Problem keeps ActualHeight to some non-zero value, which eliminates solutions based on size changes.
Try setting the property Focusable="False" in XAML

wpf scrollviewer dialogbox

I have a question about WPF's ScrollViewer
This is the code I currently have:
<Window x:Class="BasketNovelEditor.Menu.AboutBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowStartupLocation="CenterOwner"
Title="AboutBox" Height="Auto" Width="425" Focusable="True" SizeToContent="Height">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="200"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" MinHeight="50" VerticalContentAlignment="Center" HorizontalContentAlignment="Center">Thank you!</Label>
<Label Grid.Row="1" MinHeight="30" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">BasketNovel uses the following Libraries:</Label>
<Button Grid.Row="3" DockPanel.Dock="Bottom" IsDefault="True" IsCancel="True">Close Window</Button>
<ScrollViewer Grid.Row="2" Margin="5" Height="200">
<StackPanel>
</StackPanel>
</ScrollViewer>
</Grid>
And these are the results I'm getting:
http://i1280.photobucket.com/albums/a500/daegon123/ss.png
http://i1280.photobucket.com/albums/a500/daegon123/ss_zps3d6b8c90.png
I have absolutely no idea why my scrollbar is showing up like this.
I was at least expecting the up/down arrows to be placed at the start/end points
of the scrollbar.
Anyone have a clue as to why this is happening?
I'm not sure if this has anything to do with it, but the Window is
being used as a dialog box called as follows:
aboutbox.ShowDialog();
I'm currently using .NET 4.0
--EDIT2--
After a bit of testing, I realised that this would happen in all my modal windows
if I placed scrollviewers in them. The scrollviewer in my main window looks fine,
so I'm getting the feeling this is something modal window specific, or something
I may be doing to them without knowing. Anyone have any ideas?
Have you tried moving the Height="200" to the StackPanel instead?
This for some reason has been resolved after an update to Visual Studio 2012 update2.
I'm still using .NET 4.0
Encountered with the same problem in 2019, with VS2019 Community. ScrollViewer worked just fine in Main Window, but in Modal Window it doesn't scroll at all.
I set Height to the ScrollViewer and to the StackPanel, and it start worked fine.
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" PanningMode="Both" Height="340">
Also I played with different versions of .NET Framework

WP7/Silverlight: how to disable/remove adctrol from visual tree

I am building a app that supports trial and I want to show ads in trials and no ads in paid. Upon investigation I found that the only way to disable the ads for paid version is to remove the adcontrol completely from the visual tree.
Now my question is how do I remove the adcontrol from my visual tree in my code when I detect it is a paid version and not a trial. Can you please help?
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
...
</Grid>
<Grid Grid.Row="1">
...
</Grid>
<Grid Grid.Row="2">
<ad:AdControlx:Name="itemAds" .../>
</Grid>
</Grid>
If you set the Visibility of the control to Visibility.Collapsed it will be removed from the visual tree.
You therefore just need one line of code:
itemAds.Visibility = Visibility.Collapsed;
You don't even need to name the grid:
var parent = itemAds.Parent as Grid;
if (parent != null)
{
parent.Children.Remove(itemAds);
}
Could you name the Grid that is wrapping the AdControl and then call, myGrid.Children.Clear() ?

Resources