mvvm-light

Control different DataContext

删除回忆录丶 提交于 2019-12-12 16:05:52
问题 Control different DataContext in WPF As I can deploy multiple DataContext in different tabs and control which is the current DataContext I'm using Mvvm Light WPF4 i have the different ViewModels, View but i dont know how to handle multiples DataContext and control the current DataContext for change on tab switch Edit: I've got an approach to the solution as follows: Create a ViewModel for the MainView The tabcontrol source is a ObservableCollection Each TabItem has its own DataContext The

Data sharing between multiple ViewModels

和自甴很熟 提交于 2019-12-12 13:32:04
问题 Further to my question how can I bind Bing Pushpins from multiple models? This is pretty new to me and I have been searching through the web but there seem so many different approaches to MVVM and then adding in WP7 and I have got a bit confused I am now trying to work out the best way to share data between ViewModels or even if that is the best way to do it. What I mean is I have, for example My models: PeopleModel, BuildingModel My ViewModels: PeopleViewModel, BuildingViewModel (which

Visual Studio 2010 error: Type universe cannot resolve assembly

旧时模样 提交于 2019-12-12 10:52:57
问题 I've loaded a WPF project initially created in Visual Studio 2008 into Visual Studio 2010. The conversion process goes smoothly, but on certain XAML files the VS2010 designer throws several errors related to project references, including this one: System.Reflection.Adds.UnresolvedAssemblyException Type universe cannot resolve assembly: GalaSoft.MvvmLight, Version=3.0.0.31869, Culture=neutral, PublicKeyToken=3e875cdb3903c512. This assembly reference works just fine in the Expression Blend 4

How to bind absolute coordinates of a shape/control inside Canvas

非 Y 不嫁゛ 提交于 2019-12-12 10:24:06
问题 On a Windows 8.1 Metro app, I'm trying bind a collection of shapes from my view model into MainPage.xaml. Each shape will have a Left , Top and also a PathData which will be a RectangleGeometry that contains the rectangle that I want drawn inside the canvas at the corresponding position. This is the XAML : <Grid Background="Black"> <ItemsControl ItemsSource="{Binding Shapes}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Canvas /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel>

Android DataBinding - How to Bind A ViewGroup's Properties

久未见 提交于 2019-12-12 06:50:48
问题 I am developing an Android app in Xamarin.Android(C#). However, i do feel that this question can also be answered by any Java devs as well. I am new in android development. Anyways, i created a fragment with just a LinearLayout and a TextView inside it. When i create the background class for it, i don't inherit(on in JAVA's word, extend ) it from the Fragment class but rather from the LinearLayout class. So, the MyFragment.cs file starts like this : public class MyFragment : LinearLayout The

Mvvm Light UWP Index Of Listitem When Button In ListItem Is Pressed

孤街浪徒 提交于 2019-12-12 05:18:00
问题 My issue: I got a ListView which has a ItemTemplate; containing a DataTemplate with some AppBarButtons in it. Now when the user is pressing one of the Buttons in the ListView the ListItem which is containing the button doesn't get highlighted. This Problem also leads to the issue that I don't know how to get the index of the listitem which is containing the button the user clicked. ListItem: The code in Mainpage.xaml : <ListView.ItemTemplate> <DataTemplate> <StackPanel Orientation="Vertical">

WPF Autocompletebox MVVM how to get selectedItem from another control?

a 夏天 提交于 2019-12-12 04:57:05
问题 I try to develop a WPF user control (image below) that allows me to search customer by name or Number. To achieve this, I use MVVM Approach (MVVM Light). How can i achieve the following goals at the same time : 1°) If I know the number I can enter it in the textbox and the name will automatically appear in the AutoCompleteBox 2°) If the customer number is unknown ,i use autocompletebox to search by name, then the Textbox must contain the number of selected customer . The problem is : If i

Multiple viewmodels sharing a service with notification

微笑、不失礼 提交于 2019-12-12 04:56:47
问题 Question: I have two viewmodels that share a service with a list. My question is how to setup the notification so that both viewmodels know when this list is changed. Description below and code of where i'm at. I found this example HERE that looks right for what I'm trying to do, but I have a question regarding how to be notified in my viewmodels of a change in my service. I'll add some code I've mocked up to see if I'm on the right track. I'm using WPF/MVVM Light. First part is a service

Creating generalized user controls with MVVM Light

怎甘沉沦 提交于 2019-12-12 04:34:29
问题 How to create a general user control using MVVM Light? All the main views in the application seem to work fine. However, general controls doesn't seem to accept bindings. This is my FileDiplay control. An icon and a TextBlock displaying a filename next to it. Utilization In one of the main views, I try to bind a FileName inside an ItemsTemplate of an ItemsControl . Specifying a literal, like FileName="xxx" works fine, but binding doesn't. <local:FileLink FileName="{Binding FileName}" /> I've

SimpleChildWindows binded to View Model

心不动则不痛 提交于 2019-12-12 04:22:30
问题 I'm using MVVM Light, MahApps and SimpleChildWindows. I want to be able to create a CRUD Form in a modal popup. This CRUD form must be binded to its own ViewModel and called by a command in another ViewModel. I don't succeed to do this with SimpleChildWindows... So... Is it possible? 回答1: How I solved similar problem for myself, taking advantage of Dependency Injection: I used Unity and registered dependency to 'Func': public partial class App { protected override void OnStartup