Search Results

Search found 895 results on 36 pages for 'viewmodel'.

Page 6/36 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Will the changes of a property in a "StaticResource instance" reflected in UI ?

    - by Anish
    I have used object data provider to create instance of my view-model as below: <ObjectDataProvider x:Key="Datas" ObjectType="{x:Type ViewModel:UserControlViewModel}"> </ObjectDataProvider> <DataTemplate x:Key="SourceGrid"> <WPFToolKit:DataGrid x:Name="SourceDataGrid" ItemsSource="{Binding Source={StaticResource Datas},Path=SourceGridData}" CanUserSortColumns="True" GridLinesVisibility="None" IsSynchronizedWithCurrentItem="True" SelectionUnit="FullRow"></WPFToolKit:DataGrid> </DataTemplate> My question is... as I am using the instance - "Datas" as staticResource, will the changes to the property "SourceGridData" get reflected in UI? ItemsSource="{Binding Source={StaticResource Datas},Path=SourceGridData}" `

    Read the article

  • WPF InotifyPropertyChanged and view models

    - by Joel Barsotti
    So I think I'm doing something pretty basic. I know why this doesn't work, but it seems like there should be a straight foward way to make it work. code: private string fooImageRoot; // .... public BitmapImage FooImage { get { URI imageURI = new URI(Path.Combine(fooImageRoot, CurrentFooTypes.FooObject.FooImageName)); return imageURI; } } So CurrentFOoTypes and FooObject also supports INotifyPropertyChanged. So If I bind a TextBlock to CurrentFooTypes.FooObject.FooImageName, if either fooObject or FooImageName change the textblock updates. How can I subscribe my viewmodel object to recieve updates in a similiar fasion.

    Read the article

  • WPF MVVM: How do ViewModels communicate with each other?

    - by Dev1
    I have a View which has 2 sub views on it and a ViewModel is assigned to each view: ViewA - ViewModelA { ViewB - ViewModelB ViewC - ViewModelC } ViewB has a text box and ViewC has a combobox, both of which i need access from ViewModelA. Not the GUI control itself, but the bound value i.e. .Text of the textbox and .SelectedItem of the ComboBox. Currently i just have ViewModelB and ViewModelC as properties on ViewModelA but it feels wrong. What's the standard way for view models to communicate with each other without breaking the MVVM pattern? I'm completely new to WPF/MVVM.

    Read the article

  • How to handle ViewModel and Database in C#/WPF/MVVM App

    - by Mike B
    I have a task management program with a "Urgency" field. Valid values are Int16 currently mapped to 1 (High), 2 (Medium), 3 (Low), 4 (None) and 99 (Closed). The urgency field is used to rank tasks as well as alter the look of the items in the list and detail view. When a user is editing or adding a new task they select or view the urgency in a ComboBox. A Converter passes Strings to replace the Ints. The urgency collection is so simple I did not make it a table in the database, instead it is a, ObservableCollection(Int16) that is populated by a method. Since the same screen may be used to view a closed task the "Closed" urgency must be in the ItemsSource but I do not want the user to be able to select it. In order to prevent the user from being able to select that item in the ComboBox but still be able to see it if the item in the database has that value should I... Manually disable the item in the ComboBox in code or Xaml (I doubt it) Change the Urgency collection from an Int16 to an Object with a Selectable Property that the isEnabled property of the ComboBoxItem Binds to. Do as in 2 but also separate the urgency information into its own table in the database with a foreign key in the Tasks table None of the above (I suspect this is the correct answer) I ask this because this is a learning project (My first real WPF and first ever MVVM project). I know there is rarely one Right way to do something but I want to make sure I am learning in a reasonable manner since it if far harder to Unlearn bad habits Thanks Mike

    Read the article

  • WPF MVVM ViewModel constructor designmode

    - by Snake
    Right, I've got a main wpf window: <Window x:Class="NorthwindInterface.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ViewModels="clr-namespace:NorthwindInterface.ViewModels" Title="MainWindow" Height="350" Width="525"> <Window.DataContext> <ViewModels:MainViewModel /> </Window.DataContext> <ListView ItemsSource="{Binding Path=Customers}"> </ListView> </Window> And the MainViewModel is this: class MainViewModel : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged = delegate { }; public MainViewModel() { Console.WriteLine("test"); using (NorthwindEntities northwindEntities = new NorthwindEntities()) { this.Customers = (from c in northwindEntities.Customers select c).ToList(); } } public List<Customer> Customers { get;private set; } Now the problem is that in designermode I can't see my MainViewModel, it highlights it saying that it can't create an instance of the MainViewModel. It is connecting to a database. That is why (when I comment the code the problem is solved). But I don't want that. Any solutions on best practices around this?

    Read the article

  • Refactoring Bloated ViewModel

    - by Holy Christ
    Hi, I am writing a PRISM/MVVM/WPF application. It's a LOB application, so there are a lot of complicated rules. I've noticed the View Model is starting to get bloated. There are two main issues. One is that to maintain MVVM, I'm doing a lot of things that feel hacky like adding a bunch of properties to my VM. The view binds to those properties to keep track of what feels like view specific information. For example, a boolean keeping track of the status of a long running process in the VM, so the view can disable some of its controls while the long running process is working. I've read that this issue could be solved with Attached Behaviors. I'll look more into that. In the example MVVM apps you see online, this isn't a big deal because they are over-simplified. The other issue is the number of commands in my VM. Right now there are four commands. I'm defining the commands in the VM using Josh Smith's RelayCommand (basically the DelegateCommand in PRISM) so all the business logic lives in the VM. I considered moving each command into separate unit of works. I'm not sure the best way to do this. Which patterns are you guys using to keep your VMs clean? I can already feel someone responding with "your view and VM is too complicated, you should break them into many view/VMs". It is certainly not too complicated from a Ux perspective - there are 2 buttons, a combobox, and a listbox. Also, from a logical perspective, it is one cohesive domain. Having said that, I'm very interested in hearing how others are dealing with this type of issue. Thanks for your input.

    Read the article

  • WPF MVVM Pattern, ViewModel DataContext question

    - by orangecl4now
    I used this side to create my demo application http://windowsclient.net/learn/video.aspx?v=314683 The site was very useful in getting my started and in their example, they created a file called EmployeeRepository.cs which appears to be the source for the data. In their example, the data was hard-wired in code. So I'm trying to learn how to get the data from a data source (like a DB). In my specific case, I want to get the data from a Microsoft Access DB. (READ ONLY, So I'll only use SELECT commands). using System.Collections.Generic; using Telephone_Directory_2010.Model; namespace Telephone_Directory_2010.DataAccess { public class EmployeeRepository { readonly List<Employee> _employees; public EmployeeRepository() { if (_employees == null) { _employees = new List<Employee>(); } _employees.Add(Employee.CreateEmployee("Student One", "IT201", "Information Technology", "IT4207", "Building1", "Room650")); _employees.Add(Employee.CreateEmployee("Student Two", "IT201", "Information Technology", "IT4207", "Building1", "Room650")); _employees.Add(Employee.CreateEmployee("Student Three", "IT201", "Information Technology", "IT4207", "Building1", "Room650")); } public List<Employee> GetEmployees() { return new List<Employee>(_employees); } } } I found another example where an Access DB is used but it doesn't comply with MVVM. So I was trying to figure out how to add the DB file to the project, how to wire it up and bind it to a listbox (i'm not that far yet). Below is my modified file using System.Collections.Generic; using Telephone_Directory_2010.Model; // integrating new code with working code using Telephone_Directory_2010.telephone2010DataSetTableAdapters; using System.Windows.Data; namespace Telephone_Directory_2010.DataAccess { public class EmployeeRepository { readonly List<Employee> _employees; // start // integrating new code with working code private telephone2010DataSet.telephone2010DataTable employeeTable; private CollectionView dataView; internal CollectionView DataView { get { if (dataView == null) { dataView = (CollectionView) CollectionViewSource.GetDefaultView(this.DataContext); } return dataView; } } public EmployeeRepository() { if (_employees == null) { _employees = new List<Employee>(); } telephone2010TableAdapter employeeTableAdapter = new telephone2010TableAdapter(); employeeTable = employeeTableAdapter.GetData(); this.DataContext = employeeTable; } public List<Employee> GetEmployees() { return new List<Employee>(_employees); } } } I get the following error messages when building Error 1 'Telephone_Directory_2010.DataAccess.EmployeeRepository' does not contain a definition for 'DataContext' and no extension method 'DataContext' accepting a first argument of type 'Telephone_Directory_2010.DataAccess.EmployeeRepository' could be found (are you missing a using directive or an assembly reference?) C:\Projects\VS2010\Telephone Directory 2010\Telephone Directory 2010\DataAccess\EmployeeRepository.cs 23 90 Telephone Directory 2010

    Read the article

  • debugging loadwith has subnodes in domainservice, but not when called in viewmodel

    - by Jakob
    Hi, I'm trying to use the .LoadWith method I have these lines of code in my domainservice: public IEnumerable<Subject> GetSubjectList(Guid userid) { DataLoadOptions loadopts = new DataLoadOptions(); loadopts.LoadWith<Subject>(s => s.Notes); this.DataContext.LoadOptions = loadopts; return this.DataContext.Subjects; } I can see debugging that a list of subjects get loaded, and that the Subjects.Notes property which is a List is also populated with subitems, but when I do ctx.Load(ctx.GetSubjectListQuery(WebContext.Current.User.UserId), lo => { serverdata = ctx.Subjects; }, null); I only get a flat list of subjects loaded into serverdata, and no note subitems are loaded to subject.notes

    Read the article

  • ASP.NET MVC pass information from controller to view WITHOUT ViewData, ViewModel, or Session

    - by josh
    I have a unique scenario where I want a base controller to grab some data and store it in a list. The list should be accessible from my views just as ViewData is. I will be using this list on every page and would like a cleaner solution than just shoving it in the ViewDataDictionary. After attempting to come up with a solution, I thought I would create a custom ViewPage with a property to hold my list. My custom ViewPage would inherit from System.Web.MVC.ViewPage. However, I do not know where MVC passes the viewdata from the controller off to the view. More importantly, how do I get it to pass my list down to the view? Thanks for the help.

    Read the article

  • MVVM View reference to ViewModel

    - by BrettRobi
    I'm using MVVM in a WPF app. I'm very new to both. Let me state that I am not a purest in the MVVM pattern, I am trying to use as many best practices as I can but am trying to make what I think are reasonable compromises to make it work in our environment. For example, I am not trying to achieve 0% code in my View codebehind. I have a couple of questions about best practices. 1) I understand I don't want my VM to know about the attached View, but is it reasonable for the View to have a reference to its VM? 2) If a control in a View opens another View (such as a dialog) should I handle this in the View? It seems wrong to handle it in the VM since then the VM has some knowledge of a specific View.

    Read the article

  • binding a command inside a listbox item to a property on the viewmodel parent

    - by giddy
    I've been working on this for about an hour and looked at all related SO questions. My problem is very simple: I have HomePageVieModel: HomePageVieModel +IList<NewsItem> AllNewsItems +ICommand OpenNewsItem My markup: <Window DataContext="{Binding HomePageViewModel../> <ListBox ItemsSource="{Binding Path=AllNewsItems}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock> <Hyperlink Command="{Binding Path=OpenNews}"> <TextBlock Text="{Binding Path=NewsContent}" /> </Hyperlink> </TextBlock> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> The list shows fine with all the items, but for the life of me whatever I try for the Command won't work: <Hyperlink Command="{Binding Path=OpenNewsItem, RelativeSource={RelativeSource AncestorType=vm:HomePageViewModel, AncestorLevel=1}}"> <Hyperlink Command="{Binding Path=OpenNewsItem, RelativeSource={RelativeSource AncestorType=vm:HomePageViewModel,**Mode=FindAncestor}**}"> <Hyperlink Command="{Binding Path=OpenNewsItem, RelativeSource={RelativeSource AncestorType=vm:HomePageViewModel,**Mode=TemplatedParent}**}"> I just always get : System.Windows.Data Error: 4 : Cannot find source for binding with reference .....

    Read the article

  • What types of objects should the ViewModel reference in the MVVM pattern?

    - by Blanthor
    I've seen quite a few examples of MVVM. I can see that the View should reference the ViewModel. I've seen recently an example of a ViewModel referencing a View, which seems wrong to me, as it would result in tighter coupling. Given that ViewModel is often described as an intermediary between the View and the Model, is there more to the ViewModel than a facade to domain objects? I hope I used the term "facade" correctly here.

    Read the article

  • Pass view to viewmodel with datatemplate

    - by jpsstavares
    I have a ParameterView and ParameterViewModel, and I need the ParameterViewModel to have a reference to the Parameter view (more on that later). In the window I have a list of ParameterViewModels and in the ResourceDictionary I add the DataTemplate: <DataTemplate DataType="{x:Type my:ParameterViewModel}" > <my:ParameterView HorizontalAlignment="Left"/> </DataTemplate> I then bind an ItemsControl.ItemSource to the List of ParameterViewModels The problem is: How can I pass the ParameterView to the ParameterViewModel in this scenario? The reason I need the ParameterView in the ParameterViewModel is the following: I have a TextBox whose Text property is binded to the PropertyModelView.Name property. But I want to display a default string when the Name is empty or Null. I've tried to set the property value to the default string I want when that happens but the TextBox.Text is not set in this scenario. I do something like this: private string _name; public string Name { get { return _name; } set { if (value == null || value.Length == 0) Name = _defaultName; else _name = value; } } I've also tried to specifically set the TextBox.Text binding mode to TwoWay without success. I think this is a defense mechanism to prevent an infinite loop from happening but I don't know for sure. Any help on this front would also be highly appreciated. Thanks, José Tavares

    Read the article

  • WPF Binding to a viewmodel

    - by user832747
    I'm simply binding a WPF DataGridTextColumn with a binding to my grid rows. <DataGridTextColumn Header="Name" Binding="{Binding Name}" /> I've bound to my row view models. The Name property has a PRIVATE setter. public string Name { get { return _name; } private set { _name = value; } } Shouldn't the datagrid prevent me from accessing the private setter? The grid allows me to access it. I swear it never used to, unless I'm forgetting something?

    Read the article

  • WPF items not visible when grouping is applied

    - by Tri Q
    Hi, I'm having this strange issue with my ItemsControl grouping. I have the following setup: <ItemsControl Margin="3" ItemsSource="{Binding Communications.View}" > <ItemsControl.GroupStyle> <GroupStyle> <GroupStyle.ContainerStyle> <Style TargetType="{x:Type GroupItem}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type GroupItem}"> <Expander> <Expander.Header> <Grid> <Grid.ColumnDefinitions > <ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <TextBlock Text="{Binding ItemCount, StringFormat='{}[{0}] '}" FontWeight="Bold" /> <TextBlock Grid.Column="1" Text="{Binding Name, Converter={StaticResource GroupingFormatter}, StringFormat='{}Subject: {0}'}" FontWeight="Bold" /> </Grid> </Expander.Header> <ItemsPresenter /> </Expander> </ControlTemplate> </Setter.Value> </Setter> </Style> </GroupStyle.ContainerStyle> </GroupStyle> </ItemsControl.GroupStyle> <ItemsControl.ItemTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <TextBlock FontWeight="Bold" Text="{Binding Inspector, Converter={StaticResource NameFormatter}, StringFormat='{}From {0}:'}" Margin="3" /> <TextBlock Text="{Binding SentDate, StringFormat='{}{0:dd/MM/yy}'}" Grid.Row="1" Margin="3"/> <TextBlock Text="{Binding Message }" Grid.Column="1" Grid.RowSpan="2" Margin="3"/> <Button Command="vm:CommunicationViewModel.DeleteMessageCommand" CommandParameter="{Binding}" HorizontalAlignment="Right" Grid.Column="2">Delete</Button> </Grid> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> In my ViewModel, I expose a CollectionViewSource named 'Communications'. I proceed to adding a grouping patter like so: Communications.GroupDescriptions.Add(new PropertyGroupDescription("Subject")); Now, the problem i'm experience is the grouping work fine, but I can't see any items inside the groups. What am I doing wrong? Any pointers would be much appreciated.

    Read the article

  • Why should ViewModel route actions to Controller when using the MVCVM pattern?

    - by Lea Hayes
    When reading examples across the Internet (including the MSDN reference) I have found that code examples are all doing the following type of thing: public class FooViewModel : BaseViewModel { public FooViewModel(FooController controller) { Controller = controller; } protected FooController Controller { get; private set; } public void PerformSuperAction() { // This just routes action to controller... Controller.SuperAction(); } ... } and then for the view: public class FooView : BaseView { ... private void OnSuperButtonClicked() { ViewModel.PerformSuperAction(); } } Why do we not just do the following? public class FooView : BaseView { ... private void OnSuperButtonClicked() { ViewModel.Controller.SuperAction(); // or, even just use a shortcut property: Controller.SuperAction(); } }

    Read the article

  • strange data annotations issue in MVC 2

    - by femi
    Hello, I came across something strange when creating an edit form with MVC 2. i realised that my error messages come up on form sumission even when i have filled ut valid data! i am using a buddy class which i have configured correctly ( i know that cos i can see my custom errors). Here is the code from the viewmodel that generates this; <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<TG_Careers.Models.Applicant>" %> <script src="/Scripts/MicrosoftAjax.js" type="text/javascript"></script> <script src="/Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script> <script src="/Scripts/MicrosoftMvcValidation.js" type="text/javascript"></script> <%= Html.ValidationSummary() %> <% Html.EnableClientValidation(); %> <% using (Html.BeginForm()) {%> <div class="confirm-module"> <table cellpadding="4" cellspacing="2"> <tr> <td><%= Html.LabelFor(model => model.FirstName) %> </td> <td><%= Html.EditorFor(model => model.FirstName) %></td> </tr> <tr> <td colspan="2"><%= Html.ValidationMessageFor(model => model.FirstName) %></td> </tr> <tr> <td><%= Html.LabelFor(model => model.MiddleName) %></td> <td><%= Html.EditorFor(model => model.MiddleName) %></td> </tr> <tr> <td colspan="2"><%= Html.ValidationMessageFor(model => model.MiddleName) %></td> </tr> <tr> <td><%= Html.LabelFor(model => model.LastName) %></td> <td><%= Html.EditorFor(model => model.LastName) %></td> </tr> <tr> <td colspan="2"><%= Html.ValidationMessageFor(model => model.LastName) %></td> </tr> <tr> <td><%= Html.LabelFor(model => model.Gender) %></td> <td><%= Html.EditorFor(model => model.Gender) %></td> </tr> <tr> <td colspan="2"><%= Html.ValidationMessageFor(model => model.Gender) %></td> </tr> <tr> <td><%= Html.LabelFor(model => model.MaritalStatus) %></td> <td> <%= Html.EditorFor(model => model.MaritalStatus) %></td> </tr> <tr> <td colspan="2"><%= Html.ValidationMessageFor(model => model.MaritalStatus) %></td> </tr> <tr> <td><%= Html.LabelFor(model => model.DateOfBirth) %></td> <td><%= Html.EditorFor(model => model.DateOfBirth) %></td> </tr> <tr> <td colspan="2"><%= Html.ValidationMessageFor(model => model.DateOfBirth) %></td> </tr> <tr> <td><%= Html.LabelFor(model => model.Address) %></td> <td><%= Html.EditorFor(model => model.Address) %></td> </tr> <tr> <td colspan="2"><%= Html.ValidationMessageFor(model => model.Address) %></td> </tr> <tr> <td><%= Html.LabelFor(model => model.City) %></td> <td><%= Html.EditorFor(model => model.City) %></td> </tr> <tr> <td colspan="2"><%= Html.ValidationMessageFor(model => model.City) %></td> </tr> <tr> <td><%= Html.LabelFor(model => model.State) %></td> <td><%= Html.EditorFor(model => model.State) %></td> </tr> <tr> <td colspan="2"><%= Html.ValidationMessageFor(model => model.State) %></td> </tr> <tr> <td><%= Html.LabelFor(model => model.StateOfOriginID) %></td> <td><%= Html.DropDownList("StateOfOriginID", new SelectList(ViewData["States"] as IEnumerable, "StateID", "Name", Model.StateOfOriginID))%></td> </tr> <tr> <td colspan="2"><%= Html.ValidationMessageFor(model => model.StateOfOriginID) %></td> </tr> <tr> <td><%= Html.LabelFor(model => model.CompletedNYSC) %></td> <td><%= Html.EditorFor(model => model.CompletedNYSC) %></td> </tr> <tr> <td colspan="2"><%= Html.ValidationMessageFor(model => model.CompletedNYSC) %></td> </tr> <tr> <td><%= Html.LabelFor(model => model.YearsOfExperience) %></td> <td><%= Html.EditorFor(model => model.YearsOfExperience) %></td> </tr> <tr> <td colspan="2"><%= Html.ValidationMessageFor(model => model.YearsOfExperience) %></td> </tr> <tr> <td><%= Html.LabelFor(model => model.MobilePhone) %></td> <td><%= Html.EditorFor(model => model.MobilePhone) %></td> </tr> <tr> <td colspan="2"><%= Html.ValidationMessageFor(model => model.MobilePhone) %></td> </tr> <tr> <td><%= Html.LabelFor(model => model.DayPhone) %></td> <td> <%= Html.EditorFor(model => model.DayPhone) %></td> </tr> <tr> <td colspan="2"><%= Html.ValidationMessageFor(model => model.DayPhone) %></td> </tr> <tr> <td><%= Html.LabelFor(model => model.CVFileName) %></td> <td><%= Html.EditorFor(model => model.CVFileName) %></td> </tr> <tr> <td colspan="2"><%= Html.ValidationMessageFor(model => model.CVFileName) %></td> </tr> <tr> <td><%= Html.LabelFor(model => model.CurrentPosition) %></td> <td><%= Html.EditorFor(model => model.CurrentPosition) %></td> </tr> <tr> <td colspan="2"><%= Html.ValidationMessageFor(model => model.CurrentPosition) %></td> </tr> <tr> <td><%= Html.LabelFor(model => model.EmploymentCommenced) %></td> <td><%= Html.EditorFor(model => model.EmploymentCommenced) %></td> </tr> <tr> <td colspan="2"><%= Html.ValidationMessageFor(model => model.EmploymentCommenced) %></td> </tr> <tr> <td><%= Html.LabelFor(model => model.DateofTakingupCurrentPosition) %></td> <td><%= Html.EditorFor(model => model.DateofTakingupCurrentPosition) %></td> </tr> <tr> <td colspan="2"><%= Html.ValidationMessageFor(model => model.DateofTakingupCurrentPosition) %></td> </tr> <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr> <tr> <td colspan="2">&nbsp;</td> </tr> </table> <p> <input type="submit" value="Save Profile Details" /> </p> </div> <% } %> Any ideas on this one please? Thanks

    Read the article

  • How to build the ViewModel in MVVM not to violate the Single Responsibility Principle?

    - by Przemek
    Robert Martin says: "There should never be more than one reason for a class to change". Let's consider the ViewModel class which is bound to a View. It is possible (or even probable) that the ViewModel consists of properties that are not really related to each other. For small views the ViewModel may be quite coherent, but while the application gets more complex the ViewModel will expose data that will be subject to change for different and unrelated reasons. Should we worry about the SRP principle in the case of ViewModel class or not?

    Read the article

  • Josh Smith's MVVM Demo App: Add commands to MainWindowViewModel's command list

    - by MAD9
    I have a question concerning Josh Smith's famous demo app on MVVM. I try building a "real" application around it to learn WPF. He creates this CommandsList in the MainWindowViewModel containing 2 Commands (create new and view all customers). This list is readonly (why? any particular reason?). I thougt it would be nice to add and remove some commands, depending on the workspace that is currently selected. Like edit or delete a customer when it has the focus and so on. How would I accomplish this?! Can I just make it a normal list and add commands? Or bind the Commands-View to a commands list of the selected workspace instead of the MainWindow? How? Any other ways? Please share your ideas! Thank you very much!

    Read the article

  • Mapping and metadata information could not be found for EntityType Exception

    - by dcompiled
    I am trying out ASP.NET MVC Framework 2 with the Microsoft Entity Framework and when I try and save new records I get this error: Mapping and metadata information could not be found for EntityType 'WebUI.Controllers.PersonViewModel' My Entity Framework container stores records of type Person and my view is strongly typed with class PersonViewModel which derives from Person. Records would save properly until I tried to use the derived view model class. Can anyone explain why the metadata class doesnt work when I derive my view model? I want to be able to use a strongly typed model and also use data annotations (metadata) without resorting to mixing my storage logic (EF classes) and presentation logic (views). // Rest of the Person class is autogenerated by the EF [MetadataType(typeof(Person.Metadata))] public partial class Person { public sealed class Metadata { [DisplayName("First Name")] [Required(ErrorMessage = "Field [First Name] is required")] public object FirstName { get; set; } [DisplayName("Middle Name")] public object MiddleName { get; set; } [DisplayName("Last Name")] [Required(ErrorMessage = "Field [Last Name] is required")] public object LastName { get; set; } } } // From the View (PersonCreate.aspx) <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<WebUI.Controllers.PersonViewModel>" %> // From PersonController.cs public class PersonViewModel : Person { public List<SelectListItem> TitleList { get; set; } } // end class PersonViewModel

    Read the article

  • MVC map to nullable bool in model

    - by fearofawhackplanet
    With a view model containing the field: public bool? IsDefault { get; set; } I get an error when trying to map in the view: <%= Html.CheckBoxFor(model => model.IsDefault) %> Cannot implicitly convert type 'bool?' to 'bool'. An explicit conversion exists (are you missing a cast?) I've tried casting, and using .Value and neither worked. Note the behaviour I would like is that submitting the form should set IsDefault in the model to true or false. A value of null simply means that the model has not been populated.

    Read the article

  • MVC2 Binding isn't working for Html.DropDownListFor<>

    - by devlife
    I'm trying to use the Html.DropDownListFor< HtmlHelper and am having a little trouble binding on post. The HTML renders properly but I never get a "selected" value when submitting. <%= Html.DropDownListFor( m => m.TimeZones, Model.TimeZones, new { @class = "SecureDropDown", name = "SelectedTimeZone" } ) %> [Bind(Exclude = "TimeZones")] public class SettingsViewModel : ProfileBaseModel { public IEnumerable TimeZones { get; set; } public string TimeZone { get; set; } public SettingsViewModel() { TimeZones = GetTimeZones(); TimeZone = string.Empty; } private static IEnumerable GetTimeZones() { var timeZones = TimeZoneInfo.GetSystemTimeZones().ToList(); return timeZones.Select( t = new SelectListItem { Text = t.DisplayName, Value = t.Id } ); } } I've tried a few different things and am sure I am doing something stupid... just not sure what it is :)

    Read the article

  • MVVM/ViewModels and handling Authorization

    - by vdh_ant
    Hey guys Just wondering how how people handle Authorization when using MVVM and/or View Models. If I wasn't using VM's I would be passing back the Model and it would have a property which I could check if a user can edit a given object/property but when using MVVM I am disconnecting myself from the business object... and thus doen't know what the security should be any more. Is this a case where the mapper should be aware of the Authorization that is in place and don't copy across the data if the Authorization check fails. If this was the case I am guessing that the mapper would have to see some properties on the VM to let the interface know which fields are missing data because of the Authorization failure. If this does occur within the mapper, how does this fit in with things like AutoMapper, etc. Cheers Anthony

    Read the article

  • WPF/MVVM: How can I use several CollectionView`s for aggregated entities ?

    - by msfanboy
    Hello, I have a Customer with Orders and those have products. Everything aggregated with collections of type ObservableCollection. All 3 collections are bound to a datagrid/combobox. I can only make the root collection (ObservableCollection Customers{ get;set;} ) passing to a CollectionView so I can move the current customer within the combobox. But how can I move around the current Order in the datagrid? How to pass the selected Orders to another CollectionView ? Does all this maybe not work?

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >