silverlight

What are the common relationships between Views, Models, and ViewModels?

血红的双手。 提交于 2020-01-02 06:25:33
问题 I'm working on a Windows Phone 7 app with a designer. I've done C# development with XNA so I know C# but was not familiar with the Model/View/ViewModel architecture. Our first crack at it had multiple ViewModels active for any given view. Each ViewModel was an in-between layer for each object in our model. For example: We had a "Friends" page that has a ListBox that displays the list of Friends. So we made a FriendsListViewModel that would handle getting an ObservableCollection<Friend> from

TemplateBinding fails when the target is an ImageBrush.ImageSource

倾然丶 夕夏残阳落幕 提交于 2020-01-02 05:34:31
问题 Why does TemplateBinding seems to fail in this specific case? Take a basic extended button: public class IconButton : Button { public ImageSource Icon { get { return (ImageSource)GetValue(IconProperty); } set { SetValue(IconProperty, value); } } public static readonly DependencyProperty ImageProperty = DependencyProperty.Register("Icon", typeof(ImageSource), typeof(IconButton), new PropertyMetadata(null)); public IconButton() { DefaultStyleKey = typeof(IconButton); } } The control template

How to put behavior in style for TextBox in Silverlight?

人盡茶涼 提交于 2020-01-02 05:34:06
问题 In Xaml, I can put customized behavior for a textbox like: <TextBox> <i:Interaction.Behaviors> <My:TextBoxNewBehavior/> </i:Interaction.Behaviors> </TextBox> I want to all TextBox has this behavior, so how to put this behavior in implicit style like? <Style TargetType="TextBox"> <Setter Property="BorderThickness" Value="1"/> .... </Style> Update: Thanks for info. Try the way as suggested below and the app is crashed: <Setter Property="i:Interaction.Behaviors"> <Setter.Value> <My

(Caliburn Micro) Mapping a ActionMessage Methodname to a Child Object of the ViewModel

自古美人都是妖i 提交于 2020-01-02 05:25:25
问题 I would like to bind the methodname propererty of the caliburn.micro actionmessage to a method on a child object of the ViewModel. How I would imagine it should work: <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <cal:ActionMessage MethodName="MenuItemX.Clicked" /> </i:EventTrigger> </i:Interaction.Triggers> The problem here is that the methodname does not live directly on the viewmodel, but on a childobject of the viewmodel. So in this case I would like to bind to: ViewModel

Calling WCF Service from Silverlight

我只是一个虾纸丫 提交于 2020-01-02 05:13:29
问题 Im calling a locally hosted wcf service from silverlight and I get the exception below. Iv created a clientaccesspolicy.xml, which is situated in the route of my host. <?xml version="1.0" encoding="utf-8"?> <access-policy> <cross-domain-access> <policy> <allow-from http-request-headers="*"> <domain uri="*"/> </allow-from> <grant-to> <resource path="/" include-subpaths="true"/> </grant-to> </policy> </cross-domain-access> </access-policy> An error occurred while trying to make a request to URI

DataGridTextColumn - How to bind IsReadonly?

笑着哭i 提交于 2020-01-02 05:04:48
问题 In Silverlight 4, the IsReadOnly property of DataGridTextColumn seems to be no dependency property. Hence I could not bind it to a property on the viewmodel. It seems the only alternative is using a DataTemplate, but even here I am facing two major problems: <sdk:DataGrid Style="{StaticResource DataGridStyle}" x:Name="call_dataGrid" ItemsSource="{Binding Calls}"> <sdk:DataGrid.Columns> <sdk:DataGridTextColumn Header="Call Time" Binding="{Binding Path=CallTime}" /> <sdk:DataGridTemplateColumn

Silverlight WCF Service Cross Domain Question

删除回忆录丶 提交于 2020-01-02 04:50:28
问题 I have a silverlight app (hosted at intranet.mydomain.net) and a WCF service at (webservices.mydomain.net) Do I need a cross-site policy file? If so, what would it look like to only allow access from intranet.mydomain.net? 回答1: Yes, you will need a clientaccesspolicy.xml file in the ROOT of your service domain(webservices.mydomain.net). By default, Silverlight supports calls to Web services on the same domain or site of origin. Same domain means that calls must use the same sub domain,

Silverlight 3 alternative to FileVersionInfo.GetVersionInfo

霸气de小男生 提交于 2020-01-02 04:45:14
问题 Within a Silverlight 3.0 application I want to use the AssemblyFileVersion to display the version information of the application. This is not the same as the AssemblyVersion and is typically retrieved in a .NET application using code such as: var executingAssembly = Assembly.GetExecutingAssembly(); var fileVersionInfo = FileVersionInfo.GetVersionInfo(executingAssembly.Location); var versionLabel = fileVersionInfo.FileVersion; Unfortunately Silverlight 3.0 runtime does not include the

Why won't Silverlight handle the conversion of my custom float property

你。 提交于 2020-01-02 04:40:10
问题 In a Silverlight 4 project I have a class that extends Canvas: public class AppendageCanvas : Canvas { public float Friction { get; set; } public float Restitution { get; set; } public float Density { get; set; } } I use this canvas in Blend by dragging it onto another control and setting the custom properties: alt text http://www.farseergames.com/storage/share/PropertyInBlend.Png When I run the app, I get the following error when InitializeComponent is called on the control containing my

Create a HUE color bar

强颜欢笑 提交于 2020-01-02 04:33:08
问题 I'm creating a color picker and I am at a stage where I need to create a HUE color bar: One way to create it would be through gradient stops in XAML. For example: <Rectangle Width="50" Height="100"> <Rectangle.Fill> <LinearGradientBrush StartPoint="0.5,0.025" EndPoint="0.5,1" > <GradientStop Color="#FFFF0000" /> <GradientStop Color="#FEFFFF00" Offset="0.15" /> <GradientStop Color="#FE00FF00" Offset="0.3" /> <GradientStop Color="#FE00FFFF" Offset="0.45" /> <GradientStop Color="#FE0000FF"