Silverlight 2 (beta1) Known Issues and workarounds (if any)
1 Apr,2008 Silverlight
The following is the list of kNown issues for Silverlight 2 beta 1.
But this is not something new. If you keep on reading Silverlight Forum,you may already aware of those issues. but I wrote this post for those who are not aware of those issues. If you are facing some strange issues,please come and check before spending too much time for finding why something is not working as expected. I hope that you will find it useful. The most of issues are confirmed by Yi-Lun (MSFS) in our forum. (Thanks! Yi-Lun)
If you want to share some SL2 kNown issues that you like to share with everybody,please let me kNow.@H_502_193@
List of issues
- Binding Datagrid with Anonymous type will crash the browser
- Pressing “Delete” button after doing a few steps will crash the browser.(I will mention those steps later in this post.)
- Controls inside the canvas don’t appear until mouse hovers over them.
- TextBox - Cursor will disappear when you add the textBox after removing
- dispatcherTimer doesn’t allow event subscription after timer is started
- The exception occurs if you hide the button in Click event
- TextBox doesn’t work well with non-English keyboard
- ScrollBar HorizontalRootElement shows as artifact behind VerticalRootElement
- Border.Child - System.ArgumentException and System.AccessViolationException
- HorizontalAlignment not respected in Silverlight as in WPF
- TextBlock MouseEvent doesn’t work properly when text alignment is applied
- The storePath of Isolated Storage in Application_Startup event and the storepath in Application_Exit event are different.
Issue #1: Binding Datagrid with Anonymous type will crash the browser. Source: http://silverlight.net/forums/p/11147/36232.aspxProblem ~Binding Datagrid with Anonymous type will crash the browser
Steps to reproduce ~
- Create new SL 2 project.
- Add DataGrid in Page.xaml
view plaincopy to clipboardprint?
- <my:DataGrid x:Name="myDataGrid" Height="200" Width="700" Margin="0,5,10"
- AutoGenerateColumns="True" VerticalAlignment="Top">
- Bind this datagrid with anonymous type.
string str = string.Empty;str = @"<?xml version=""1.0"" encoding=""utf-8"" ?>";
Workarounds ~Create the class explicitly
Yi-Lun from Microsoft explained about this issue as below.
Hello,actually the problem is: Anonymous Types are internal. Currently data binding doesn’t support binding to non-public classes. Try to use a ListBox to bind to an internal class,you’ll find a similar problem.
The root cause seems to be: Data binding uses reflection,and reflection needs high security permissions. Silverlight runs in a sand box,where such security permissions are not granted.
However,I found that it’s working fine with Listbox. So,we are still discussing about this issue. I will update this post once we got the final conclusion.
Credit: Thanks to Yi-lun for verifying this issue.
Issue #2: Binding Datagrid with Anonymous type will crash the browser.Source : http://silverlight.net/forums/t/13077.aspxThere are two sub-issues in this issue.
Create new Silverlight 2 project
<TextBox x:Name="Txt" TextChanged="Txt_TextChanged" />
WordaroundsNone:
Credit: Thanks to pavelsua for reporting this issue. He reported the issue 2.1. When I tried to verify his issue,I found another one (2.2). Issue #3. Controls inside the canvas don’t appear until mouse hovers over them.
Source : http://silverlight.net/forums/t/10906.aspxSymptom: A canvas has visibility changed from Visibilty.Collapsed to Visibilty.Visible but controls inside the canvas don’t appear until mouse hovers over them.
Steps to reproduce:
1. Create a Silverlight 2 app <UserControl x:Class="SilverlightApplication3.Page"
3. Change the Visibility of cnvTest on clicking the button
public Page(){
Expected: the button in the canvas to be shown as soon as the canvas is made visible.
Workarounds ~
Credits: Thanks to AdamJTP for reporting this issue and sharing the workaround.————-
Issue #4. Cursor will disappear when you add the textbox after removingSource : http://silverlight.net/forums/p/11142/36252.aspx: The cursor of textBox won’t show when adding the textBox that is removed earlier at runtime.
~
1. The code is written in Page.xaml. There are one button for adding new textBox,another button for removing the textBox and one canvas where the textBox suppose to be added or removed.
<UserControl x:Class="SL2KnownIssue.Page"
2. The code is written in Page.xaml.cs
namespace SL2KnownIssue {
3. Run the application
4. Click “Add” button to add the textbox to the screen on the fly.
5. Try to type something in that textbox that you added. (Observe: It will be working fine as you expected.)
6. Click “Remove” button to remove the textbox and click “Add” button again.
7. then,type something in this textbox. (Observe: At this time,you are still able to type it but you won’t see the cursor anymore. )
Initially,I was thinking that the workaround would be “hiding/showing” instead of “removing and adding”. But it won’t work since we already have issue #1. So,I think there is no workaround for that. Be careful when you are trying to remove or add the element.
Credits: Thanks to sgzwkrm for reporting this issue and Yi-Lun for confirming this issue. Issue #5. DispatcherTimer doesn’t allow event subscription after timer is startedSource: http://silverlight.net/forums/p/12652/41581.aspx: dispatcherTimer doesn’t allow any event subscription after timer is started
Steps to reproduce
1. Attach the Tick event to Timer after calling Start() method
_timer = new DispatcherTimer();
Obseve: _timer_Tick will never be called.
Workaround ~Obviously,you have to attach the event before calling Start() method.
Credits: Thanks to Florian Kruesch for reporting this issue and Allen Chen for confirming this issue. @H_502_193@Issue #6. The exception occurs if you hide the button in Click event Source: http://silverlight.net/forums/p/12519/41100.aspxDescription:
Steps to reproduce ~
1. Add one button in XAML
</UserControl>
2. Attach the Click event in that button and hide it in that event
add.Visibility = Visibility.Collapsed;
3. Run the application and click the button. (Ob: You will get the following error.)
Error Message:“Error HRESULT E_FAIL has been returned from a call to a COM component”
stack trace :
Yi-Lun from Silverlight explained about this issue as below ~
Issue #7. Textbox doesn’t work well with non-English keyboardSource : http://silverlight.net/forums/t/10705.aspxSome reported that they are not able to type accented characters,like ‘é’,Alt Gr and Ctrl+’,<letter> in textBox if they are using non-English keyboard such as Spanish,German and etc.
None
Credit: Thanks to everyone who are participating in @H_502_193@this post. @H_502_193@Issue #8. ScrollBar HorizontalRootElement shows as artifact behind VerticalRootElement Source : http://silverlight.net/forums/p/12939/42610.aspx and http://silverlight.net/forums/p/10698/34561.aspxProblem : An artifact of the HorizontalRootElement (from the HorizontalThumbTemplate) is clearly visible.
Steps to reproduce ~
ElementVerticalTemplate = GetTemplateChild(ElementVerticalTemplateName) as FrameworkElement;
Credits: Thanks to jseaver and Attila for reporting this issue and thanks to Attila and Yi-Lun for showing the workarounds.Issue #9. Border.Child - System.ArgumentException and System.AccessViolationExceptionSource: http://silverlight.net/forums/p/11401/36428.aspxUsing SL2B1 with C# (and IE7),the Border control will throw an exception if the Child property is set to the same object twice.
Example:
UserControl A; myBorder.Child = A; //OK An exception of type ‘System.ArgumentException’ occurred in System.Windows.dll but was not handled in user code Also along these lines,setting Child to null produces another exception, myBorder.Child = null;
An exception of type ‘System.AccessViolationException’ occurred in System.Windows.dll but was not handled in user code Credit: Thanks to UncleRedz for reporting this issue and Pranav Goel for confirming this issue.@H_502_193@Issue #10: HorizontalAlignment not respected in Silverlight as in WPF Source: http://silverlight.net/forums/p/12636/41513.aspxProblems ~
Note: The following is reported by MichaelGG from Silverlight forum.@H_502_193@In WPF setting HorizontalAlignment on a control will let it resize itself if it’s inside a stretched element. For example:
<Window x:Class=”WpfApplication1.Window1″ This will show a button not much larger than it’s content,centered in the Window. However,doing the same in Silverlight fails:
<UserControl x:Class=”SilverlightApplication1.Page” The button is stretched across the entire window.
My WPF-layout-powers are not that strong,so it’s quite possible that I’m missing something here. But it does appear as if SL isn’t behaving how it should.
WorkaroundNote: The following is replied from Yi-Lun.@H_502_193@<Path x:Name="CurvedBevel" Stretch="Fill" Margin="3,3,0" Data="F1 M 0,0.02 V 0.15 C 0.15,0.22 0.30,0.25 0.50,0.26 C 0.70,0.26 0.85,0.22 1,0.15 V 0.02 L 0.97,0 H 0.02 L 0,0.02 Z">
Nice as it is,this will cause layout problems. Add this Path to a WPF’s Button’s template,and you’ll get the same result. So you have to override the Button’s template,and remove this Path or so…
Issue #11: TextBlock MouseEvent doesn’t work properly when text alignment is applied Source: http://silverlight.net/forums/t/12672.aspxAll Mouse event of TextBlock is not fired when TextAlignment =”Center” .
Steps to reproduces ~Put the following code in XAML (e.g. Page.xaml)
<TextBlock x:Name="textBlock"
private void TextBlock_MouseMove(object sender, MouseEventArgs e)
Credit: Thanks to Jongho for reporting this issue.Issue #12: The storePath of Isolated Storage in Application_Startup event and the storepath in Application_Exit event are different.
Source: http://silverlight.net/forums/p/12247/42471.aspxThe storePath of Isolated Storage in Application_Startup event and the storepath in Application_Exit event are different.
Download the sample project from this link.(Thanks to Jong Ho for making this sample for me.)
A workaround is to cache the isolated storage path in the Startup event,or handle the html window.onunload event instead of Silverlight’s Exit event.
Credit: Thanks to bpatters for reporting this issue,Jong Ho for making the demo and Yi-lun for verifying this issue and providing the workaround.@H_502_193@That’s all for Now. I have 3 or 5 issues in my list. I will update those issue tomorrow or this weekend. If you have any kNown issue of Silverlight 2 beta1,please let me kNow.
private void Txt_TextChanged(object sender,TextChangedEventArgs e) {
Console.WriteLine(”");
}
[/sourcecode]
2. Change the Page XAML to look like this (either manually or in Blend)
at MS.Internal.XcpImports.MethodEx(IntPtr ptr,String name,CValue[] cvData)
at System.Windows.DependencyObject.MethodEx(String methodName,CValue[] cvData)
at System.Windows.UIElement.ReleaseMouseCapture()
at System.Windows.Controls.Primitives.ButtonBase.ReleaseMouseCaptureInternal()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(Object sender,MouseButtonEventArgs e)
at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex,Delegate handlerDelegate,Object sender,Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj,IntPtr unmanagedObjArgs,Int32 argsTypeIndex,String eventName)
UserControl B;
myBorder.Child = B; //OK
myBorder.Child = B; //Exception
Additional @R_72_4045@ion: Value does not fall within the expected range.
Additional @R_72_4045@ion: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
Title=”Window1″ Height=”Auto” Width=”Auto”>
<Grid>
<StackPanel>
<Button Content=”asd” HorizontalAlignment=”Center” />
</StackPanel>
</Grid>
</Window>
xmlns=”http://schemas.microsoft.com/client/2007”
Width=”Auto” Height=”Auto”>
<Grid>
<StackPanel>
<Button Content=”asd” HorizontalAlignment=”Center” />
</StackPanel>
</Grid>
</UserControl>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。