我正在使用silverlight 3.0进行申请.在那个应用程序中,我有一个公共方法
public void DrawWavform()
{
Line[,] line = new Line[10,200];
line[i,j]= new Line();//i am getting error here of invalid thread access
//some operation
}
Run Code Online (Sandbox Code Playgroud)
在应用程序中,我根据用户输入创建不同的线程,并从新创建的线程调用DrawWaveform方法.我想并行操作.请建议我解决.谢谢提前.
伙计们,我看到下面的代码在我将其粘贴到记事本中时会出现运行时错误并保存为test.xaml并运行它.
<Page xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TextBlock Text="Hi Ramakrishnan, good morning"/>
<Button x:Name=”blueButton”
Width=”100”
Height=”40”
Background=”Blue”
Content=”Click Me” />
</Page>
Run Code Online (Sandbox Code Playgroud)
但是下面的代码没有给出任何错误,但在浏览器中非常正确地显示了文本块内容.有什么想法吗 ?我还检查了包括一个文本框代替上面的按钮,仍然是同样的错误.
<Page xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TextBlock Text="Hi Ramakrishnan, good morning"/>
</Page>
Run Code Online (Sandbox Code Playgroud) 我已经安装了VS-2012 Express Edition.现在,我正在尝试创建Silverlight应用程序.
在一开始我结束时出现以下错误:
您需要在创建Silverlight项目之前安装最新的Silverlight Developer运行时.从以下位置下载x86运行时:go.microsoft.com/fwlink/?LinkId=229323
因此,我从上面给出的URL下载了Silverlight Developer运行时,我尝试再次创建Silverlight应用程序.
当我点击New Project对话框上的OK按钮时,我收到以下错误.
可能是什么原因?任何人都可以建议解决方案是什么?

错误摘要如下:
System.Reflection.TargetInvocationException调用目标抛出了异常.在Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.WaitForCompletion(NestedCallContext nestedCallContext,BlockingCall通话,WaitHandle的timeoutSignal)在Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.MarshalOutSynchronous(行动行动,的Int32 targetApartmentId,WaitHandle的中止,WaitHandle的timeoutSignal )Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.MarshalOut(Action action,Int32 targetApartmentId,WaitHandle aborted,CallSynchronizationMode syncMode,WaitHandle timeoutSignal)at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.MarshalOut [TValue](RemoteHandle)Microsoft.Expression.DesignHost.IsolatedDesignerService.IsolatedDesignerView上的Microsoft.Expression.DesignHost.Isolation.Remoting.LocalDesignerService.Microsoft.Expression.DesignHost.IDesignerService.CreateDesigner(IHostSourceItem项目,IHostTextEditor编辑器,CancellationToken cancelToken)中的
1 targetObject, Action action, CallSynchronizationMode syncMode) at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.MarshalOut[TResult,TValue](RemoteHandle1个targetObject,Func2 func, CallSynchronizationMode syncMode) at Microsoft.Expression.DesignHost.Isolation.Remoting.LocalDesignerService.CreateDesignerImpl(IHostSourceItem item, IHostTextEditor editor, RemoteCancellationToken remoteCancelToken) at Microsoft.Expression.DesignHost.Isolation.Remoting.LocalDesignerService.<>c__DisplayClass12.<Microsoft.Expression.DesignHost.IDesignerService.CreateDesigner>b__11(RemoteCancellationToken remoteToken) at Microsoft.Expression.DesignHost.Isolation.Remoting.LocalDesignerService.CallWithCancellation[TResult](CancellationToken cancelToken, Func2 func). CreateDesignerViewInfo(Cancellati onToken cancelToken)System.Reflection.TargetInvocationException调用目标抛出了异常.
服务器堆栈跟踪:Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.WaitForCompletion(NestedCallContext nestedCallContext,BlockingCall call,WaitHandle timeoutSignal)at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.MarshalIn(Action action,Int32 targetApartmentId)at at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.MarshalIn(IRemoteObject targetObject,Action action)at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.MarshalIn [TResult](IRemoteObject targetObject,Func`1 func)at Microsoft.Expression System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md,Object [.DesignHost.Isolation.Remoting.RemoteDesignerService.Microsoft.Expression.DesignHost.Isolation.Remoting.IRemoteDesignerService.CreateDesigner(IRemoteHostSourceItem …
如果我的asp.net网站有一些silverlight内容(XAP文件,silverlight视频内容),用户每次在浏览器中打开我的网站时都必须下载所有内容,或者即使用户关闭计算机,日期也会保存/缓存在硬盘上?在什么文件夹中保存数据以及保存多长时间?在创建silverlight项目时,我在某处阅读了"通过使用应用程序库缓存减少XAP大小"选项.默认情况下是否启用该选项(在VS中没有安装Silverlight)?
我们正在寻找一种方法来了解我们的silverligth或Web应用程序在哪台计算机上运行.我们首先希望通过MAC地址来做,但我们发现silverligth无法访问mac地址.
我想知道有没有办法获得一个独特的计算机地址像mac地址或其他PC独特?通过silverligth/javascript/html或其他基于网络的东西在他们的电脑上安装任何东西?
Thx Matthy
在我的应用程序B中,我需要检查是否安装了应用程序A. 如果一个已安装,乙将调用一个.
如果一个尚未安装,乙就会去市场下载一个.
如何实现这个???
任何建议都会很棒!
谢谢!
我在SL/WPF中经历了一些MVVM示例,这里最基本的是实现ICommand接口.我已经理解了MVVM的工作原理.但是,我Execute对ICommand接口方法有疑问.
实现的类ICommand具有Execute如下所示的方法.
public void Execute(object parameter) //Method to call when the command is invoked
{
// pointer to a method to be executed
}
Run Code Online (Sandbox Code Playgroud)
在每个例子中,我都看到上面方法中的参数是NULL.为什么?有人可以发布一个MVVM的简单示例,其中使用此对象参数而不是null吗?
假设我有以下课程:
public class Values {
public string Value1 {get;set;}
public string Value2 {get;set;}
public string Value3 {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
现在我想使用IValueConverter以特定顺序将此对象的值绑定到GUI组件的ItemsSource:
public class ValuesToListConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var valuesObj = (Values ) value;
yield return valuesObj.Value1;
yield return valuesObj.Value3;
yield return valuesObj.Value2;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我这样做时,我收到以下错误:
'Convert'的主体不能是迭代器块,因为'object'不是迭代器接口类型.
有没有办法在IValueConverter中懒洋洋地创建这个列表?或者我必须这样做:
return new List<string> { valuesObj.Value1, valuesObj.Value3, valuesObj.Value2 }
Run Code Online (Sandbox Code Playgroud) 目前,我有一个包含3列的网格行:文本(带填充缩进),虚线和图标.我希望结果如下:

问题是我无法修复文本和图标之间的绘制线宽,它不是虚线,如下所示:

这是我的数据模板:
<DataTemplate x:Key="TreeItemTemplate">
<Grid Width="456">
<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="6*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<!-- Text -->
<TextBlock Margin="0,0,1,0" Visibility="{Binding NormalTextVisible}" TextWrapping="Wrap" Text="{Binding Name, Mode=TwoWay}" d:LayoutOverrides="Width, Height" Foreground="{Binding Colour}" Padding="{Binding ActualIndent, Mode=TwoWay}" FontSize="{StaticResource PhoneFontSizeMedium}"/>
<!-- Line-->
<Path Grid.Column="1" Stroke="Red" StrokeThickness="2" StrokeDashArray="1 2 3" Stretch="Fill">
<Path.Data>
<LineGeometry StartPoint="0,1" EndPoint="1,1" />
</Path.Data>
</Path>
<!-- Icon-->
<Grid Grid.Column="2" HorizontalAlignment="Right" >
<Button Style="{StaticResource IconButton}" Height="42" Width="42" HorizontalAlignment="Right">
<ImageBrush ImageSource="{Binding Image}" Stretch="None"/>
</Button>
</Grid>
</Grid>
</DataTemplate>
Run Code Online (Sandbox Code Playgroud)
而我的列表框:
<ListBox x:Name="lstTreeView" HorizontalAlignment="Stretch" VerticalAlignment="Top" …Run Code Online (Sandbox Code Playgroud) 我正在尝试通过WCF服务访问Silverlight应用程序的SQL数据库,由于某种原因,我的SqlDataReader对象一直给我错误.我只是试图从数据库中检索一个单一的值.
这是我现在的代码:
using(SqlConnection oConnection = new SqlConnection(ConnectionString))
{
SqlCommand oCommand = new SqlCommand("SELECT SystemVersNo FROM dbo.CoPolicyPointer WHERE SystemAssignId = '58859700000000'");
CompositeType oCustomer = new CompositeType();
SqlDataReader oReader = null;
oConnection.Open();
oCommand.Connection = oConnection;
oReader = oCommand.ExecuteReader();
if (oReader.HasRows)
{
oCustomer.SRVNo = oReader.GetValue(0).ToString();
}
else
{
oCustomer.SRVNo = "No rows returned.";
}
oConnection.Close();
return oCustomer;
}
Run Code Online (Sandbox Code Playgroud)
oReader.HasRows返回true,但oReader.GetValue(0)(或oReader.GetAnythingElse,就此而言)抛出一个错误:
System.InvalidOperationException:没有数据时读取的尝试无效.
然而,真正令我困惑的是,如果我打电话oReader.GetOrdinal("SystemVersNo"),或者oReader.GetName(0),他们都返回正确的价值观.序数位置如何以零返回,但是在该位置找不到要读取的值?如果我在SQL Server Management Studio中运行相同的查询,那么值就没问题了,所以我知道它就在那里.
我对这一切都是全新的,我错过了一些基本的东西吗?或者有什么时髦的事情发生.
谢谢!
silverlight ×10
c# ×7
wpf ×2
drawing ×1
html ×1
javascript ×1
line ×1
mac-address ×1
mvvm ×1
wcf ×1
wpf-controls ×1
xaml ×1