mvvm-light

WPF ViewBox blocks VisualTreeHelper search

混江龙づ霸主 提交于 2019-12-11 15:17:02
问题 I have tried this Navigation Service approach (View First) for MVVM-Light WPF https://stackoverflow.com/a/28968560/5272185 I realized that the VisualTreeHelper search for the Frame element does not find the Frame if the Frame is located inside a ViewBox. Is there a good explanation of such strange behaviour? Is it possible to work around it? 回答1: It turned out that the example code in the link was the problem. If you run into this type of problem I recommend to read the following from Josh

Unregister Message in Destructor make error ({“Handle is not initialized.”})

浪子不回头ぞ 提交于 2019-12-11 13:44:00
问题 Is there anyone who experienced the same error like me: Situation: - I'm using MVVMLight v4 with my window application: - I have a windows form : such as mainform - In code-behind class (mainform.xaml.cs), I have a constructor & a deconstructor: public mainform() { Messenger.Default.Register<NotificationMessage>( this, msg => { //// Do something } } ~mainform() { Messenger.Default.Unregister<NotificationMessage>(this); } Those code run well, but when the form is closed, an exception will be

MVVMLight and WP7 RTM

不羁的心 提交于 2019-12-11 12:39:17
问题 Does the MVVMLight version that worked before with the WP7 Beta work with WP7 RTM? 回答1: It sure does, but the one gotcha that still exists. If you're using the templates, is that it doesn't set the ProductID uniquely. While you tend not to see this problem pop up on the emulator, it can cause big problems on an actuall device as the device get's confused with what application is what. To fix the problem, open up the Properties\WMAppManifest.xml file and modify the ProductID attribute on the

Cannot find resource named 'ViewModelLocator' exception

笑着哭i 提交于 2019-12-11 10:36:55
问题 I am trying to use ViewModelLocator by declaring it as a resource in App.xaml. Its a very simple class as follows: public class ViewModelLocator { public ShellViewModel ShellPage { get { return new ShellViewModel(); } } } App.xaml file is as below: <Application x:Class="SomeNamespace.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:vm="clr-namespace:SomeNamespace.ViewModels"> <Application.Resources> <vm

Change brushes based on ViewModel property

£可爱£侵袭症+ 提交于 2019-12-11 10:26:01
问题 I have an application which has CarViewModel + view ( UserControl ). What I want to achieve is to change the style of brushes when the bound DataContext Car.Status changes. I found out how to change the brushes (in code behind of the view): private void LoadThemeResources(bool isPrepareMode) { if (isPrepareMode) { Uri themeUri = new Uri(@"/../Resources/MyBrushes.Light.xaml", UriKind.Relative); ResourceDictionary themeDictionary = Application.LoadComponent(themeUri) as ResourceDictionary; this

Sending Generic Messages

对着背影说爱祢 提交于 2019-12-11 07:56:08
问题 public class Foo<T> where T: Entity {} public class Foo1 : Foo<Telephone> { } public class Foo2 : Foo<Home> { } How do I send Foo1 to Foo2? I realize that the message is typed, and hence messages of the same type of recieved - but I need to message between the derived classes... An example would be very much appreciated. 回答1: the messaging in mvvmlight is in theory supposed to be fire and forget...the sender doesnt care who gets the message and the receiver doesnt care who sends the message,

Practical example of using Castle.Windsor with MVVMLight Toolkit

ぃ、小莉子 提交于 2019-12-11 07:28:53
问题 I have really tried but I cannot find a good working example of using the Castle IOC with MVVMLight. Any sort of guidance in the way to dynamically generate ViewModelBase viewmodels would be appreciated. I am trying to use Constructor Injection to associate the viewmodel with a data source, something like: public class MainViewModel : ViewModelBase { ... public MainViewModel( ISomeSortofDataRepsoitory mysomesortofdata) myrepo = mysomesortofdata; /// data items in an observable collection }

PropertyChanged for all Properties: Message=Property not found

淺唱寂寞╮ 提交于 2019-12-11 06:57:53
问题 I want to raise PropertyChanged for all 20 Properties of my ViewModel in once and get the solution: RaisePropertyChanged(String.Empty) see: C#/WPF: PropertyChanged for all Properties in ViewModel? Since I use GalaSoft.MvvmLight.ViewModelBase.RaisePropertyChanged of MVVM Light, I get the runtime error: Message=Property not found ParamName="" Source=GalaSoft.MvvmLight.WPF4 This is because MVVM Light check all Property-Names. What can I do? 回答1: If you look at the source, you'll see that this

MVVM-Light EventToCommand Behavior for CheckBox Checked/Unchecked in Silverlight

北城以北 提交于 2019-12-11 06:36:06
问题 I would like to handle the Checked and Unchecked events of a Checkbox control and execute a command in my ViewModel. I wired up an EventTrigger for both the Checked and Unchecked events as follows: <CheckBox x:Name="chkIsExtendedHr" IsChecked="{Binding Schedule.Is24Hour, Mode=TwoWay}"> <i:Interaction.Triggers> <i:EventTrigger EventName="Checked"> <GalaSoft_MvvmLight_Command:EventToCommand CommandParameter="{Binding IsChecked, ElementName=chkIsExtendedHr}" Command="{Binding Path=SetCloseTime,

OnNavigatedTo is called two twice on app resuming

江枫思渺然 提交于 2019-12-11 06:29:31
问题 I'm having trouble with my WP8 app. It uses the MVVM light library for the creation of the ViewModel and is also used for the page navigation with Messages. Right now I'm having some problems with the OnNavigatedTo Method of my MainPage. If I start the app for the first time, it is called once. If I close and reopen it with the back button, it is also only called once. The constructor of my MainPage ViewModel will also be called only once. If I let the application open in the background and