Search Results

Search found 1189 results on 48 pages for 'mvvm'.

Page 11/48 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • MVVM-Light Loaded Evented Executing Twice

    - by user275561
    Let me show the code first, The Control <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Controls:MatrixGrid x:Name="matrixGrid"> <i:Interaction.Triggers> <i:EventTrigger EventName="Loaded"> <cmd:EventToCommand Command="{Binding MatrixLoaded}" CommandParameter="{Binding ElementName=matrixGrid}" /> </i:EventTrigger> </i:Interaction.Triggers> </Controls:MatrixGrid> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> In The ViewModel Class I have public RelayCommand<MatrixGrid> MatrixLoaded { get; private set; } In The Constructor of the View Model I have MatrixLoaded = new RelayCommand<MatrixGrid>(MatrixGridAction); Now When I put a Breakpoint on the Function MatrixGridAction, The breakpoint is hit twice. Am I doing something wrong or is this a bug?

    Read the article

  • Refreshing Read-Only (Chained) Property in MVVM

    - by Wonko the Sane
    I'm thinking this should be easy, but I can't seem to figure this out. Take these properties from an example ViewModel (ObservableViewModel implements INotifyPropertyChanged): class NameViewModel : ObservableViewModel { Boolean mShowFullName = false; string mFirstName = "Wonko"; string mLastName = "DeSane"; private readonly DelegateCommand mToggleName; public NameViewModel() { mToggleName = new DelegateCommand(() => ShowFullName = !mShowFullName); } public ICommand ToggleNameCommand { get { return mToggleName; } } public Boolean ShowFullName { get { return mShowFullName; } set { SetPropertyValue("ShowFullName", ref mShowFullName, value); } } public string Name { get { return (mShowFullName ? this.FullName : this.Initials); } } public string FullName { get { return mFirstName + " " + mLastName; } } public string Initials { get { return mFirstName.Substring(0, 1) + "." + mLastName.Substring(0, 1) + "."; } } } The guts of such a [insert your adjective here] View using this ViewModel might look like: <TextBlock x:Name="txtName" Grid.Row="0" Text="{Binding Name}" /> <Button x:Name="btnToggleName" Command="{Binding ToggleNameCommand}" Content="Toggle Name" Grid.Row="1" /> The problem I am seeing is when the ToggleNameCommand is fired. The ShowFullName property is properly updated by the command, but the Name binding is never updated in the View. What am I missing? How can I force the binding to update? Do I need to implement the Name properties as DependencyProperties (and therefore derive from DependencyObject)? Seems a little heavyweight to me, and I'm hoping for a simpler solution. Thanks, wTs

    Read the article

  • WPF MVVM Property Change Animation

    - by cjibo
    I am looking for a clean way to start an animation that will have dynamic values. Basically I want to do an animation where an element changes width based on the data of another element. Say I have a TextBlock that's Text Property is Binding. When this property changes I want a visual element say a Rectangle for our sake to do a DoubleAnimation changing the width from previous value to the new value. I am trying to stay away from putting code in my view if possible. I've looked into DataTriggers but they seem to require that you know what the value would be such as an Enum. In my case it is just the value changing that needs to trigger a storyboard and the animation would need to start at the current(previous) value and move nicely to the new value. Any ideas. Maybe I just missed a property.

    Read the article

  • A view model mvvm design issue

    - by Chen Kinnrot
    the best way to explain is with example so: this is the model public class Person { public int age; public string name; } this is the view model public class PersonVM { } my question is: should the vm expose the person to the datga template or encapsulate the model properties with his own properties?

    Read the article

  • Simple Binding question, unable to bind to button command in a DataTemplate using MVVM Light Toolkit

    - by deliberative assembly
    I've been attempting to bind to buttons within a DataTemplate without much success. The button does not fire. Button Click works successfully outside of the DataTemplate. Yet if I create a Click="button_click" the click button is fired. The Button Content binds perfectly as well. Example to illustrate.. Why does the command not fire? Advice on how this should be handled this? The example is a simplified version of my real problem, I am currently not using a Listbox. I only recreated the same problem with a listbox..

    Read the article

  • C# - Silverlight - MVVM

    - by cmaduro
    I want to use UserControl as the base for my views, but I cannot add functionality to my views because they are based on UserControl. How do I create my own view class by using a subclassed version of UserControl.

    Read the article

  • MVVM and division of amongst multiple developers

    - by nlawalker
    Can anyone speak to the ease of dividing work amongst multiple developers when designing and building a medium- to large-complexity Silverlight or WPF application? My team is finding it difficult to cleanly split work when you've got, for example, a number of controls that provide different visualizations of a Model/ViewModel that's fairly complex and has a lot of properties and methods for interacting with data. It seems like a very big portion of the work ends up being the design and build of the Model/ViewModel, and much less inside each of the controls, which are naturally what are easy to ration out to multiple people.

    Read the article

  • drag-drop and data binding in MVVM

    - by Benny
    My ViewModel: class ViewModel { public string FileName {get;set;} } and in my View I bind a label's content to ViewModel's FileName. now When I do drag-drop a file to my View, How can I update the label's Content property, so that the ViewMode's FileName also get updated via binding? Directly set the label's Content property won't work, it just simply clear the binding.

    Read the article

  • MVVM and avoiding Monolithic God object

    - by bufferz
    I am in the completion stage of a large project that has several large components: image acquisition, image processing, data storage, factory I/O (automation project) and several others. Each of these components is reasonably independent, but for the project to run as a whole I need at least one instance of each component. Each component also has a ViewModel and View (WPF) for monitoring status and changing things. My question is the safest, most efficient, and most maintainable method of instantiating all of these objects, subscribing one class to an Event in another, and having a common ViewModel and View for all of this. Would it best if I have a class called God that has a private instance of all of these objects? I've done this in the past and regretted it. Or would it be better if God relied on Singleton instances of these objects to get the ball rolling. Alternatively, should Program.cs (or wherever Main(...) is) instantiate all of these components, and pass them to God as parameters and then let Him (snicker) and His ViewModel deal with the particulars of running this projects. Any other suggestions I would love to hear. Thank you!

    Read the article

  • Silverlight textblock binding question + MVVM

    - by AdrianDN
    Hello everyone, I'm trying to create a simple textblock control and I'm trying to insert a property from my ViewModel in the middle of the string. E.G. "Hello, My name is XX, bla, bla." (XX is a property from my ViewModel) <TextBlock Text="Hello, My name is {Binding SelectedUser.Name}, bla, bla." /> Is that possible? Regards, Adrian

    Read the article

  • Selecting the usercontrol to the relating datatemplate in mvvm

    - by msfanboy
    Hello, I have lets say a WeeklyViewUserControl.xaml and a DailyViewUserControl.xaml. Normally I used stuff like this to switch content: <DataTemplate DataType="{x:Type ViewModel:LessonPlannerViewModel}"> <View:LessonPlannerDailyUC/> </DataTemplate> This worked so far. But now I have still the WeeklyViewUC which uses 90 % of the LessonPlannerViewModel code so I want to make this additionally: <DataTemplate DataType="{x:Type ViewModel:LessonPlannerViewModel}"> <View:LessonPlannerWeeklyUC/> </DataTemplate> but this can not work, because from where does the ContentControl know that VM (LessonPlannerViewModel) should display a DailyViewUC or a WeeklyViewUC ? <ContentControl Content="{Binding VM}" />

    Read the article

  • WPF MVVM TreeView item source losing context after command

    - by user3955716
    I have a treeview which contains files, every view model holds an item source which is an ObservableCollection with files items: public ObservableCollection<CMItemFileNode> SubItemNode On each item i have context menu options (Delete, Execute..). If i move from one viewModel to another the ObservableCollection of files updated correctly and presented correctly but, when i perform a context menu command like delete file item, the command execute good but when i move to another view model (which holds SubItemNode ObservableCollection of is own) after the command executed the WPF still thinks i'm in the last view model i was in and not the one i'm really on. Very important to mention is that when i update to .net 4.5 (which unfortunantly i can't do) everything is ok and the ObservableCollection addresses the correct view model. Here is the treeView: <TreeView x:Name="Files" Margin="0,5,5,0" Grid.Row="6" Grid.Column="2" ItemsSource="{Binding SubItemNode}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalAlignment="Stretch" Height="300" Grid.RowSpan="6" Width="300" dd:DragDrop.IsDragSource="True" dd:DragDrop.IsDropTarget="True" dd:DragDrop.DropHandler="{Binding}" dd:DragDrop.UseDefaultDragAdorner="True"> <TreeView.Resources> <Style TargetType="{x:Type TreeView}"> <Setter Property="local:CMTreeViewFilesBehavior.IsTreeViewFilesBehavior" Value="True"/> </Style> <Style TargetType="{x:Type TreeViewItem}"> <Setter Property="IsSelected" Value="{Binding IsSelected}" /> <Setter Property="local:CMTreeViewFilesItemBehavior.IsTreeViewFilesItemBehavior" Value="True"/> </Style> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" /> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" /> </TreeView.Resources> <TreeView.ContextMenu> <ContextMenu> <MenuItem Header="View File" Command="{Binding ExecuteFileCommand}" /> <Separator /> <MenuItem Header="Delete all" Command="{Binding DeleteAllFilesCommand}" /> <MenuItem Header="Delete selected" Command="{Binding DeleteSelectedFilesCommand}" /> </ContextMenu> </TreeView.ContextMenu> <TreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding SubItemNode}" > <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Image Grid.Column="0" Margin="2" Width="32" Height="18" Source="{Binding Path=Icon}" HorizontalAlignment="Left" VerticalAlignment="Center" /> <TextBlock Text="{Binding Path=Name}" Grid.Column="1" Margin="2" VerticalAlignment="Center" Foreground="{Binding Path=Status, Converter={StaticResource ItemFileStatusToColor}}" FontWeight="{Binding Path=IsSelected, Converter={StaticResource BoolToFontWidth}}"/> </Grid> </HierarchicalDataTemplate> </TreeView.ItemTemplate> </TreeView> Am I doing somthing wrong? and why in .net 4.5 it works well ?

    Read the article

  • Silverlight 4 Treeview MVVM WCF

    - by Coppermine
    I'm having an issue with the treeview control from the silverlight 4 toolkit. I can't get it to view to display my data correctly, the toplevel items are shown but the childnodes are nowhere to be seen. More info: I have a wcf service that delivers a list of Categories with nested subcategories to my viewmodel (I made sure to explicitly include my subcategory data). My viewmodel has an observable list property (wich is named Categories) with this data from my WCF service. My ViewModel: _http://pastebin.com/0TpMW3mR My XAML: http://pastebin.com/QCwVeyYu

    Read the article

  • MVVM Binding To Property == Null

    - by LnDCobra
    I want to show some elements when a property is not null. What is the best way of achieving this? The following is my ViewModel: class ViewModel : ViewModelBase { public Trade Trade { get { return _trade; } set { SetField(ref _trade, value, () => Trade); } } private Trade _trade; } ViewModelBase inherits INotifyPropertyChanged and contains SetField() The Following is the Trade class: public class Trade : INotifyPropertyChaged { public virtual Company Company { get { return _company; } set { SetField(ref _company, value, () => Company); } } private Company _company; ...... } This is part of my View.xaml <GroupBox Visibility="{Binding Path=Trade.Company, Converter={StaticResource boolToVisConverter}}" /> I would like this groupbox to show only if Trade.Company is not null (so when a user selects a company). Would I need to create a custom converter to check for null and return the correct visibility or is there one in .NET?

    Read the article

  • Display Consistent Value of an Item using MVVM and WPF

    - by Blake Blackwell
    In my list view control (or any other WPF control that will fit the situation), I would like to have one TextBlock that stays consistent for all items while another TextBlock that changes based on the value in the ObservableCollection. Here is how my code is currently laid out: XAML <ListView ItemsSource="{Binding Path=MyItems, Mode=TwoWay}"> <ListView.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock x:Name="StrVal" Text="{Binding StrVal}" /> <TextBlock x:Name="ConstVal" Text="{Binding MyVM.ConstVal}" /> </StackPanel> </DataTemplate> </ListView.ItemTemplate> </ListView> Model public class MyItem { public string StrVal { get; set; } } ViewModel public class MyVM { public MyVM() { ObservableCollection<MyItem> myItems = new ObservableCollection<MyItem>(); for (int i = 0 ; i < 10; i++) myItems.Add(new MyItem { StrVal = i.ToString()}); MyItems = myItems; ConstVal = "1"; } public string ConstVal { get; set; } public ObservableCollection<MyItem> MyItems { get; set; } } Code Behind this.DataContext = new MyVM(); The StrVal property repeats correctly in the ListView, but the ConstVal TextBlock does not show the ConstVal that is contained in the VM. I would guess that this is because the ItemsSource of the ListView is MyItems and I can't reference other variables outside of what is contained in the MyItems. My question is: How do I get ConstVal to show the value in the ViewModel for all listviewitems that will be controlled by the Observable Collection of MyItems.

    Read the article

  • C# generics with MVVM, pulling the T out of <T>

    - by bufferz
    My Model is a generic class that contains a (for example) Value property which can be int, float, string, bool, etc. So naturally this class is represented something like Model<T>. For the sake of collections Model<T> implements the interface IModel, although IModel is itself empty of any content. My ViewModel contains and instance of Model<T> and it is passed in through ViewModel's constructor. I still want to know what T is in ViewModel, so when I expose Model to the View I know the datatype of Model's buried Value property. The class for ViewModel ends up looking like the following: class ViewModel<T> { private Model<T> _model; public ViewModel(Model<T> model) { ....blah.... } public T ModelsValue {get; set; } } This works fine, but is limited. So now I need to expose a collection of IModels with varying Ts to my View, so I'm trying to set up an ObservableCollection of new ViewModel<T>s to a changing list of IModels. The problem is, I can't figure out how to get T from Model<T> from IModel to construct ViewModel<T>(Model<T>) at runtime. In the VS2010 debugger I can mouseover any IModel object and see its full Model<int> for example at runtime so I know the data is in there. Any ideas?

    Read the article

  • MVVM Light DialogMessage

    - by Cha0sEngine
    hi, im trying to use the mvvmlight DialogMessage. var message = new DialogMessage( "Confirm Delete", RemoveAddressAction) { Button = MessageBoxButton.OKCancel, Caption = "Caption??" }; VS2010 undelines the "Button = MessageBoxButton.OKCancel" line complaining about "Cannot convert source type 'System.Windows.MessageBoxButton [PresentationFramework, Version=3.0.0.0, Culture...] to target type 'System.Windows.MessageBoxItem [GalaSoft.MvvmLight, Version=3.0.0.29216, ...] And a similar issue on the code behind on the view when I try to use the DialogMessage to show the messagebox. Has anyone encountered this before? I have no clue how to fix it. Thanks.

    Read the article

  • C# MVVM Calculating Total

    - by LnDCobra
    I need to calculate a trade value based on the selected price and quantity. How can The following is my ViewModel: class ViewModel : ViewModelBase { public Trade Trade { get { return _trade; } set { SetField(ref _trade, value, () => Trade); } } private Trade _trade; public decimal TradeValue { get { return Trade.Amount * Trade.Price; } } } ViewModelBase inherits INotifyPropertyChanged and contains SetField() The Following is the Trade class: public class Trade : INotifyPropertyChaged { public virtual Decimal Amount { get { return _amount; } set { SetField(ref _amount, value, () => Amount); } } private Decimal _amount; public virtual Decimal Price { get { return _price; } set { SetField(ref _price, value, () => Price); } } private Decimal _price; ...... } I know due to the design my TradeValue only gets calculated once (when its first requested) and UI doesn't get updated when amount/price changes. What is the best way of achieving this? Any help greatly appreciated.

    Read the article

  • Silverlight ~ MVVM ~ Dynamic setting of Style property based on model value

    - by eponymous23
    I have a class called Question that represents a question and it's answer. I have an application that renders an ObservableCollection of Question objects. Each Question is rendered as a StackPanel that contains a TextBlock for the question verbiage, and a TextBox for the user to enter in an answer. The questions are rendered using an ItemsControl, and I have initially set the Style of the Questions's StackPanel using a StaticResource key called 'IncorrectQuestion' (defined in UserControl.Resources section of the page). In the UserControl.Resources section, I've also defined a key calld 'CorrectQuestion' which I need to somehow apply to the Question's StackPanel when the user correctly answers the question. My problem is I'm not sure how to dynamically change the Style of the StackPanel, specifically within the constraints of a ViewModel class (i.e. I don't want to put any style selection code in the View's code-behind). My Question class has an IsCorrect property which is accurately being set when the correction is answered. I'd like to somehow reflect the IsCorrect value in the form of a Style selection. How do I do that?

    Read the article

  • Distinguishing between UI command & domain commands

    - by SonOfPirate
    I am building a WPF client application using the MVVM pattern that provides an interface on top of an existing set of business logic residing in a library which is shared with other applications. The business library followed a domain-driven architecture using CQRS to separate the read and write models (no event sourcing). The combination of technologies and patterns has brought up an interesting conundrum: The MVVM pattern uses the command pattern for handling user-interaction with the view models. .NET provides an ICommand interface which is implemented by most MVVM frameworks, like MVVM Light's RelayCommand and Prism's DelegateCommand. For example, the view model would expose a number of command objects as properties that are bound to the UI and respond when the user performs actions like clicking buttons. Many implementations of the CQRS use the command pattern to isolate and encapsulate individual behaviors. In my business library, we have implemented the write model as command / command-handler pairs. As such, when we want to do some work, such as create a new order, we 'issue' a command (CreateOrderCommand) which is routed to the command-handler responsible for executing the command. This is great, clearly explained in many sources and I am good with it. However, take this scenario: I have a ToolbarViewModel which exposes a CreateNewOrderCommand property. This ICommand object is bound to a button in the UI. When clicked, the UI command creates and issues a new CreateOrderCommand object to the domain which is handled by the CreateOrderCommandHandler. This is difficult to explain to other developers and I am finding myself getting tongue-tied because everything is a command. I'm sure I'm not the first developer to have patterns overlap like this where the naming/terminology also overlap. How have you approached distinguishing your commands used in the UI from those used in the domain? (Edit: I should mention that the business library is UI-agnostic, i.e. no UI technology-specific code exists, or will exists, in this library.)

    Read the article

  • In MVVM should the ViewModel or Model implement INotifyPropertyChanged?

    - by Edward Tanguay
    Most MVVM examples I have worked through have had the Model implement INotifyPropertyChanged, but in Josh Smith's CommandSink example the ViewModel implements INotifyPropertyChanged. I'm still cognitively putting together the MVVM concepts, so I don't know if: you have to put the INotifyPropertyChanged in the ViewModel to get CommandSink to work this is just an aberration of the norm and it doesn't really matter you should always have the Model implement INotifyPropertyChanged and this is just a mistake which would be corrected if this were developed from a code example to an application What have been others' experiences on MVVM projects you have worked on?

    Read the article

  • How do I determine inactivity in a MVVM application?

    - by Jordan
    I have an MVVM kiosk application that I need to restart when it has been inactive for a set amount of time. I'm using Prism and Unity to facilitate the MVVM pattern. I've got the restarting down and I even know how to handle the timer. What I want to know is how to know when activity, that is any mouse event, has taken occurred. The only way I know how to do that is by subscribing to the preview mouse events of the main window. That breaks MVVM thought, doesn't it? I've thought about exposing my window as an interface that exposes those events to my application, but that would require that the window implement that interface which also seems to break MVVM.

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >