Search Results

Search found 1226 results on 50 pages for 'kendo mvvm'.

Page 24/50 | < Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >

  • How to handle One View with multiple ViewModel and fire different Commands

    - by Naresh
    Hi All, I have senario in which one view and view has binding with multiple ViewModel. Eg. One View displaying Phone Detail and ViewModel as per bellow: Phone basic features- PhoneViewModel, Phone Price Detail- PhoneSubscriptionViewModel, Phone Accessories- PhoneAccessoryViewModel For general properties- PhoneDetailViewModel I have placed View's general properties to PhoneViewModel.Now senario is like this: By default View displays Phone Basic feaures which is bind with ObservationCollection of PhoneViewModel. My view have button - 'View Accessories', onclick of this button one popup screen- in my design I have display/hide Grid and bind it with ObservationCollection of PhoneAccessoryViewModel. Now problem begins- Accessory List also have button 'View Detail' onclick I have to open one popup screen, here also I had placed one Grid and Visible/Hide it. I have bind 'ViewAccessoryDetailCommand' command to 'View Detail' button. And on command execution one function fires and set property which Visible the Popup screen. Using such programming command fires, function calls but the property change not raises and so my view does not display popup. Summary: One View-- ViewModel1--Grid Bind view ViewModel2 --Grid Have Button and Onclick display new Grid which binded with ViewModel3-this Command fires but property not raises. I think there is some problem in my methodology, Please, give your suggetions.

    Read the article

  • Prism Commands - binding error when binding to list element ?

    - by Maciek
    I've got a ItemsControl (to be replaced by listbox) which has it's ItemsSource bound to an ObservableCollection<User> which is located in the view model. The View Model contains some DelegateCommand<T> delegates for handling commands (for instance UpdateUserCommand and RemoveUserCommand). All works fine if the buttons linked to those commands are placed outside of the DataTemplate of the control which is presenting the items. <ItemsControl ItemsSource="{Binding Users, Mode=TwoWay}" HorizontalContentAlignment="Stretch"> <ItemsControl.ItemTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="0.2*"/> <ColumnDefinition Width="0.2*"/> <ColumnDefinition Width="0.2*"/> <ColumnDefinition Width="0.2*"/> <ColumnDefinition Width="0.2*"/> </Grid.ColumnDefinitions> <TextBlock Grid.Column="0" Text="{Binding UserName}"/> <PasswordBox Grid.Column="1" Password="{Binding UserPass}"/> <TextBox Grid.Column="2" Text="{Binding UserTypeId}"/> <Button Grid.Column="3" Content="Update" cal:Click.Command="{Binding UpdateUserCommand}" cal:Click.CommandParameter="{Binding}"/> <Button Grid.Column="4" Content="Remove" cal:Click.Command="{Binding RemoveUserCommand}" cal:Click.CommandParameter="{Binding}"/> </Grid> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> What I'm trying to achieve, is : Have each row - generated by the ListView/ItemsControl - contain buttons to manage the item represented that particular row. During the runtime, the VS's output panel generated the following messages for each listbox element System.Windows.Data Error: BindingExpression path error: 'UpdateUserCommand' property not found on 'ModuleAdmin.Services.User' 'ModuleAdmin.Services.User' (HashCode=35912612). BindingExpression: Path='UpdateUserCommand' DataItem='ModuleAdmin.Services.User' (HashCode=35912612); target element is 'System.Windows.Controls.Button' (Name=''); target property is 'Command' (type 'System.Windows.Input.ICommand').. System.Windows.Data Error: BindingExpression path error: 'RemoveUserCommand' property not found on 'ModuleAdmin.Services.User' 'ModuleAdmin.Services.User' (HashCode=35912612). BindingExpression: Path='RemoveUserCommand' DataItem='ModuleAdmin.Services.User' (HashCode=35912612); target element is 'System.Windows.Controls.Button' (Name=''); target property is 'Command' (type 'System.Windows.Input.ICommand').. Which would imply that there are binding errors present. Is there any way to make this right? or is this not the way?

    Read the article

  • What's are the best readings to start using WPF instead of WinForms?

    - by Ivan
    Keeping in mind what CannibalSmith once said - "All the answers are saying "WPF is different". That's a huge understatement. You not only have to learn lots of new stuff - you must forget everything you've learned from Forms. It's a completely new way of doing UI." .. and having many years of experience with visual Windows desktop applications development (VB6, Borland C++ Builder VCL, WinForms) (which is hard to forget), how do I quickly move to developing to say well-formed WPF applications with Visual Studio? I don't need boozy-woozy graphics to give my app look and feel of a Hollywood blockbuster or a million dollar pyjamas. I always loved tidiness of standard Windows common controls and UI design guidelines, end even more I enjoyed them under Vista Glass Aero Graphite sauce. I am perfectly satisfied with WinForms but I want to my applications to be built of the most efficient and up-to-date standard technologies and architectured according to the most efficient and flexible patterns of today and tomorrow, leveraging interface-based integration and functionality reuse and to take all advantages of modern hardware and APIs to maximize performance, usability, reliability, maintainability, extensibility, etc. I very much like the idea of separating view, logic and data, letting a view to take all advantages of the platform (may it run as a web browser applet on a thin client or as a desktop application on a PC with a latest GPU), letting logic be reused, parallelized and seamlessly evolve, storing data in a well structured format in a right place. But... while moving from VB6 to Borland C++ Builder was very easy (no books/tutorials needed to turn it on and start working) (assuming I already knew C++), moving from BCB to WinForms was the same seamless, it does not seem any obvious to me how to do with WPF. So how do I best convert myself from a WinForms developer into a right-way thinking and doing WPF developer?

    Read the article

  • web grid server pagination trigger multiple controller call when changing page

    - by Thomas Scattolin
    When I server-filter on "au" my web grid and change page, multiple call to the controller are done : the first with 0 filtering, the second with "a" filtering, the third with "au" filtering. My table load huge data so the first call is longer than others. I see the grid displaying firstly the third call result, then the second, and finally the first call (this order correspond to the response time of my controller due to filter parameter) Why are all that controller call made ? Can't just my controller be called once with my total filter "au" ? What should I do ? Here is my grid : $("#" + gridId).kendoGrid({ selectable: "row", pageable: true, filterable:true, scrollable : true, //scrollable: { // virtual: true //false // Bug : Génère un affichage multiple... //}, navigatable: true, groupable: true, sortable: { mode: "multiple", // enables multi-column sorting allowUnsort: true }, dataSource: { type: "json", serverPaging: true, serverSorting: true, serverFiltering: true, serverGrouping:false, // Ne fonctionne pas... pageSize: '@ViewBag.Pagination', transport: { read: { url: Procvalue + "/LOV", type: "POST", dataType: "json", contentType: "application/json; charset=utf-8" }, parameterMap: function (options, type) { // Mise à jour du format d'envoi des paramètres // pour qu'ils puissent être correctement interprétés côté serveur. // Construction du paramètre sort : if (options.sort != null) { var sort = options.sort; var sort2 = ""; for (i = 0; i < sort.length; i++) { sort2 = sort2 + sort[i].field + '-' + sort[i].dir + '~'; } options.sort = sort2; } if (options.group != null) { var group = options.group; var group2 = ""; for (i = 0; i < group.length; i++) { group2 = group2 + group[i].field + '-' + group[i].dir + '~'; } options.group = group2; } if (options.filter != null) { var filter = options.filter.filters; var filter2 = ""; for (i = 0; i < filter.length; i++) { // Vérification si type colonne == string. // Parcours des colonnes pour trouver celle qui a le même nom de champ. var type = ""; for (j = 0 ; j < colonnes.length ; j++) { if (colonnes[j].champ == filter[i].field) { type = colonnes[j].type; break; } } if (filter2.length == 0) { if (type == "string") { // Avec '' autour de la valeur. filter2 = filter2 + filter[i].field + '~' + filter[i].operator + "~'" + filter[i].value + "'"; } else { // Sans '' autour de la valeur. filter2 = filter2 + filter[i].field + '~' + filter[i].operator + "~" + filter[i].value; } } else { if (type == "string") { // Avec '' autour de la valeur. filter2 = filter2 + '~' + options.filter.logic + '~' + filter[i].field + '~' + filter[i].operator + "~'" + filter[i].value + "'"; }else{ filter2 = filter2 + '~' + options.filter.logic + '~' + filter[i].field + '~' + filter[i].operator + "~" + filter[i].value; } } } options.filter = filter2; } var json = JSON.stringify(options); return json; } }, schema: { data: function (data) { return eval(data.data.Data); }, total: function (data) { return eval(data.data.Total); } }, filter: { logic: "or", filters:filtre(valeur) } }, columns: getColonnes(colonnes) }); Here is my controller : [HttpPost] public ActionResult LOV([DataSourceRequest] DataSourceRequest request) { return Json(CProduitsManager.GetProduits().ToDataSourceResult(request)); }

    Read the article

  • how to reference drageventArgs in xaml as command parameter with silverlight

    - by Shaggy
    Hi, on my silverlight 4 app I am trying to link up the drop event on a list box to my viewmodel. I am using expression blend 4's event trigger and invokecommandaction to hook up the drop event. Setting break points on my viewmodel, I can see the relevant function is fired when I drag a file onto the list box, however I cant seem to get access to the drageventArgs. I tried sending the entire listbox as a command parameter, and that doesn't work. Any ideas? Thanks

    Read the article

  • How do you handle the deletion of your model working with ViewModels and keeping them in sync ?

    - by Lisa
    Hello, these could be my entity relations: 1 Pupil has 1 Chair 1 Pupil has N Documents 1 Pupil has N Marks 1 Pupil has N IncidentReports etc... So with that sample I get 4 IEnumerable from my database put each into an ObservableCollection. Now I have 4 different Views each bound to one of those 4 collections. Lets assume I delete a single PupilViewModel in the AdministrationController which is the only View where I can delete a PupilViewModel. Now I have to inform 3 other Controller and their ObservableCollections about the one deleted PupilViewModel to keep the whole application synchronized... thats stupid somehow. Do you have any good advice on that scenario? AND it gets even worse. If I delete a schoolclass I have to sync the pupils everywhere AND the documents or incidentreports or marks... gush... o_O

    Read the article

  • Silverlight 4.0 with PRISM

    - by patelsan
    Anybody has experience of building Silverlight with PRISM for LoB applications? If so, please share your experiences. I am planning to use PRISM with SL 4, in past I used Silverlight.FX with SL 3.

    Read the article

  • how to get the value of a kendoui dropdown list selected value in a listview

    - by user1568738
    am having Some kendoui listviews which consists of kendoui dropdown lists and i want to get those dropdown list selected values. To do this am trying, $("#cnty1").val(); and here is my dropdownlist,i.e., list of countries coming from Database table, <input select STYLE="width:90px;height:auto" id ="cnty1" data-bind="value:cnty1" name="cnty1" data-type="string" data-text-field="cnty" data-value-field="cntyid" data-source="sourcedata1" class="k-d" data-role="dropdownlist" /> <span data-for="cnty1" class="k-invalid-msg"></span> here cnty1 is the id of the dropdown list, but am not getting the value instead am getting "id" of the slected value but not the selected value. And also if the value is not selected am getting the first value id by using $("#cnty1").val(); So, please suggest me a solution so that, 1) I should get only the Selected value and 2) Value of the dropdown list Only if the user selects a value from the list, but don't get the value of the list without selecting.

    Read the article

  • Help with Linq Expression - INotifyPropertyChanged

    - by Stephen Patten
    Hello, I'm reading the source code from the latest Prism 4 drop and am interested in solving this problem. There is a base class for the ViewModels that implements INotifyPropertyChanged and INotifyDataErrorInfo and provides some refactoring friendly change notification. protected void RaisePropertyChanged<T>(Expression<Func<T>> propertyExpresssion) { var propertyName = ExtractPropertyName(propertyExpresssion); this.RaisePropertyChanged(propertyName); } private string ExtractPropertyName<T>(Expression<Func<T>> propertyExpresssion) { if (propertyExpresssion == null) { throw new ArgumentNullException("propertyExpression"); } var memberExpression = propertyExpresssion.Body as MemberExpression; if (memberExpression == null) { throw new ArgumentException("The expression is not a member access expression.", "propertyExpression"); } var property = memberExpression.Member as PropertyInfo; if (property == null) { throw new ArgumentException("The member access expression does not access property.","propertyExpression"); } if (!property.DeclaringType.IsAssignableFrom(this.GetType())) { throw new ArgumentException("The referenced property belongs to a different type.", "propertyExpression"); } var getMethod = property.GetGetMethod(true); if (getMethod == null) { // this shouldn't happen - the expression would reject the property before reaching this far throw new ArgumentException("The referenced property does not have a get method.", "propertyExpression"); } if (getMethod.IsStatic) { throw new ArgumentException("The referenced property is a static property.", "propertyExpression"); } return memberExpression.Member.Name; } and as an example of it's usage private void RetrieveNewQuestionnaire() { this.Questions.Clear(); var template = this.questionnaireService.GetQuestionnaireTemplate(); this.questionnaire = new Questionnaire(template); foreach (var question in this.questionnaire.Questions) { this.Questions.Add(this.CreateQuestionViewModel(question)); } this.RaisePropertyChanged(() => this.Name); this.RaisePropertyChanged(() => this.UnansweredQuestions); this.RaisePropertyChanged(() => this.TotalQuestions); this.RaisePropertyChanged(() => this.CanSubmit); } My question is this. What would it take to pass an array of the property names to an overloaded method (RaisePropertyChanged) and condense this last bit of code from 4 lines to 1? Thank you, Stephen

    Read the article

  • 'Generic' ViewModel

    - by Ian MacPherson
    Using EF 4, I have several subtypes of a 'Business' entity (customers, suppliers, haulage companies etc). They DO need to be subtypes. I am building a general viewmodel which calls into a service from which a generic repository is accessed. As I have 4 subtypes, it would be good to have a 'generic' viewmodel used for all of these. Problem is of course is that I have to call a specific type into my generic repository, for example: BusinessToRetrieve = _repository .LoadEntity<Customer>(o => o.CustomerID == customerID); It would be good to be able to call <SomethingElse>, somethingElse being one or other of the subtypes), otherwise I shall have to create 4 near identical viemodels, which seems a waste of course! The subtype entity name is available to the viewmodel but I've been unable to figure out how to make the above call convert this into a type. An issue with achieving what I want is that presumably the lambda expression being passed in wouldn't be able to resolve on a 'generic' call ?

    Read the article

  • Does WPF break an Entity Framework ObjectContext?

    - by David Veeneman
    I am getting started with Entity Framework 4, and I am getting ready to write a WPF demo app to learn EF4 better. My LINQ queries return IQueryable<T>, and I know I can drop those into an ObservableCollection<T> with the following code: IQueryable<Foo> fooList = from f in Foo orderby f.Title select f; var observableFooList = new ObservableCollection<Foo>(fooList); At that point, I can set the appropriate property on my view model to the observable collection, and I will get WPF data binding between the view and the view model property. Here is my question: Do I break the ObjectContext when I move my foo list to the observable collection? Or put another way, assuming I am otherwise handling my ObjectContext properly, will EF4 properly update the model (and the database)? The reason why I ask is this: NHibernate tracks objects at the collection level. If I move an NHibernate IList<T> to an observable collection, it breaks NHibernate's change tracking mechanism. That means I have to do some very complicated object wrapping to get NHibernate to work with WPF. I am looking at EF4 as a way to dispense with all that. So, to get EF4 working with WPF, is it as simple as dropping my IQueryable<T> results into an ObservableCollection<T>. Does that preserve change-tracking on my EDM entity objects? Thanks for your help.

    Read the article

  • RaisePropertyChanged for Windows Phone

    - by chief7
    I'm starting to use the MVVMLight framework and have a question about binding to properties in the ViewModel. I found that I have to call the RaisePropertyChanged method in the setter for the property in order for the View to be updated. And I have to call RaisePropertyChanged from through the dispatcher otherwise I get a thread access error. public string Lat { get { return _lat; } set { _lat = value; Deployment.Current.Dispatcher.BeginInvoke(() => RaisePropertyChanged("Lat")); } } This works but its a lot of code to get auto binding properties. Is there a helper to handle this more cleanly?

    Read the article

  • Binding scattered/overlapping images to a WPF Canvas

    - by bufferz
    I am porting a GDI application over to WPF, where I displayed several dozen images onto Form, then drew polygons, circles, rectangles, etc over the top of these images using GDI Pens and Brushes. I'm starting to get the hang of WPF binding and would like to store all of these images and markup graphics in my ViewModel. My VM contains an ObservableCollection of my custom DrawingEntitys, DrawingEntity contains DependencyProperties for BitmapSource, Height, Width, CanvasTopLeftY, and CanvasTopLeftX, that I update frequently in the collection. I know my binding is working, I just can't figure out how to bind and draw this collection onto a Canvas. I've played around with ItemsControl and ItemsSource to death, too many different ways to list here. I can display the DrawingEntity.Bitmaps onto the canvas but Canvas.Top won't bind to CanvasTopLeftY in the DrawingEntity, everything is overlapped at 0,0. I think I'm missing an obvious strategy. Any ideas?

    Read the article

  • Menu item for each module, with module content loading dynamically with Prism or MEF

    - by user573145
    I am developing an application currently using Prism and MEF. I would ideally like to generate a toolbar or menu with an item for each module, and when an item is clicked, only the views declared within that module load into a tab control. For example: Menu Region: ModuleA(Selected) | ModuleB Tab Region: ModuleAViewA | ModuleAViewB | ModuleAViewC Changes to Menu Region: Employees | Inventory(selected) Tab Region: Items | In Fi

    Read the article

  • Why can't I Bind a viewmodel property to a dependency property of a custom control

    - by Robert
    I want to use a color picker in my wpf application and I saw a nice looking one on this codeproject page. The control works fine until I want to connect the control to a viewmodel. I created a small test program with this viewmodel: public class ColorViewModel : ViewModelBase { public ColorViewModel() { LineColor = Brushes.Yellow; } SolidColorBrush _brushColor; public SolidColorBrush LineColor { get { return _brushColor; } set { _brushColor = value; RaisePropertyChanged(() => LineColor); } } } The test program has a textbox and the colorpicker controls: <StackPanel Orientation="Horizontal"> <TextBlock Text="Please Select a Color" FontWeight="Bold" Margin="10" Foreground="{Binding Path=LineColor, UpdateSourceTrigger=PropertyChanged}"/> <vw:ColorPickerControlView x:Name="ForeColorPicker" Margin="10" CurrentColor="{Binding Path=LineColor, UpdateSourceTrigger=PropertyChanged }"/> </StackPanel> In the loaded event of the window I set the viewmodel to the datacontext like this: DataContext = new ColorViewModel(); The problem is that I can't seem to bind the LineColor property of the viewmodel to the CurrentColor property of the ColorPickerControlView. The CurrentControl property of the ColorPickerControlView seems to be fine. The constructor looks like this: public ColorPickerControlView() { this.DataContext = this; InitializeComponent(); CommandBindings.Add(new CommandBinding(SelectColorCommand, SelectColorCommandExecute)); } In the constructor of the UserControl there is the line this.DataContext = this; I read that is is necessary to bind the dependency properties. Do I override this line when I set my viewmodel to the datacontext and is that why I can't bind to the CurrentColor property? Is there any workaround? Or did I make another mistake?

    Read the article

  • ArrangeOverride Vs Storyboard Animation

    - by user275561
    Now I may not grasp the idea or this could be a mistake so feel free to correct me. I am doing a bubble breaker game in Silverlight. So when a bubble in a column gets bursted. I want to animate the above bubbles to simulate that they are being dropped. Each bubble knows its Row and column location and that gets updated in the View Model. Now my question is, Should I call invalidateArrange() on the Canvas from the ViewModel so it rearranges the bubbles or just have a storyboard animate the TranslateY. In my arrangeOverride Method I have something like this Rect childBounds = new Rect(CalculateLeft(dataContext.Column), CalculateTop(dataContext.Row), BubbleSize, BubbleSize); child.Arrange(childBounds); If there is a better way let me know. I am trying to learn the best practices.

    Read the article

  • How to trigger binding source update from code in WPF?

    - by Benny
    In My ViewModel class I have a property: 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

  • Bind selected value on combobox to view model

    - by Shaggy
    Hi, I have my silverlight app which pulls data into a datagrid from a view model. The vm is exposed via Mef. I also have a details grid which has comboboxes. The vm also contains the data to populate the combobox values. Upon first load, everything works fine and the selected items on te comboboxes are correct and I can select alternative values. However, if I sort my main data grid (allow sort=true) then I find the binding for selected value on the comboboxes dissapear. The combobox is still populated with data but nothing is selected. Has anyone come across this issue before? I am unsure how to solve this one. Thanks

    Read the article

  • Initialization of ComboBox in datagrid, Silverlight 4.0

    - by Budda
    I have datagrid with list of MyPlayer objects linked to ItemsSource, there are ComboBoxes inside of grid that are linked to a list of inner object, and binding works correctly: when I select one of the item then its value is pushed to data model and appropriately updated in other places, where it is used. The only problem: initial selections are not displayed in my ComboBoxes. I don't know why..? Instance of the ViewModel is assigned to view DataContext. Here is grid with ComboBoxes (grid is binded to the SquadPlayers property of ViewModel): <data:DataGrid ="True" AutoGenerateColumns="False" ItemsSource="{Binding SquadPlayers}"> <data:DataGrid.Columns> <data:DataGridTemplateColumn Header="Rig." Width="50"> <data:DataGridTemplateColumn.CellTemplate> <DataTemplate> <ComboBox SelectedItem="{Binding Rigid, Mode=TwoWay}" ItemsSource="{Binding IntLevels, Mode=TwoWay}"/> </DataTemplate> </data:DataGridTemplateColumn.CellTemplate> </data:DataGridTemplateColumn> </data:DataGrid.Columns> </data:DataGrid> Here is ViewModel class ('_model_DataReceivedEvent' method is called asynchronously, when data are received from server): public class SquadViewModel : ViewModelBase<SquadModel> { public SquadViewModel() { SquadPlayers = new ObservableCollection<SquadPlayer>(); } private void _model_DataReceivedEvent(List<SostavPlayerData> allReadyPlayers) { TeamTask task = new TeamTask { Rigid = 1 }; foreach (SostavPlayerData spd in allReadyPlayers) { SquadPlayer sp = new SquadPlayer(spd, task); SquadPlayers.Add(sp); } RaisePropertyChanged("SquadPlayers"); } And here is SquadPlayer class (it's objects are binded to the grid rows): public class SquadPlayer : INotifyPropertyChanged { public SquadPlayer(SostavPlayerData spd) { _spd = spd; Rigid = 2; } public event PropertyChangedEventHandler PropertyChanged; private int _rigid; public int Rigid { get { return _rigid; } set { _rigid = value; if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("Rigid")); } } } private readonly ObservableCollection<int> _statIntLevels = new ObservableCollection<int> { 1, 2, 3, 4, 5 }; public ObservableCollection<int> IntLevels { get { return _statIntLevels; } } It is expected to have all "Rigid" comboboxes set to "2" value, but they are not selected (items are in the drop-down list, and if any value is selected it is going to ViewModel). What is wrong with this example? Any help will be welcome. Thanks.

    Read the article

  • Binding a property to change the listbox items foreground individually for each item

    - by Eyal-Shilony
    I'm trying to change the foreground color of the items in the ListBox individually for each item, I've already posted a similar question but this one is more concrete. I hoped that the state of the color is reserved for each item added to the ListBox, so I tried to create a property (in this case "HotkeysForeground"), bind it and change the color when the items are added in the "HotkeyManager_NewHotkey" event, the problem it's changing the foreground color for all the items in the ListBox. How can I do that per item ? Here is the ViewModel I use. namespace Monkey.Core.ViewModel { using System; using System.Collections.ObjectModel; using System.Windows.Media; using Monkey.Core.SystemMonitor.Accessibility; using Monkey.Core.SystemMonitor.Input; public class MainWindowViewModel : WorkspaceViewModel { private readonly FocusManager _focusManager; private readonly HotkeyManager _hotkeyManager; private readonly ObservableCollection<string> _hotkeys; private Color _foregroundColor; private string _title; public MainWindowViewModel() { _hotkeys = new ObservableCollection<string>(); _hotkeyManager = new HotkeyManager(); _hotkeyManager.NewHotkey += HotkeyManager_NewHotkey; _focusManager = new FocusManager(); _focusManager.Focus += FocusManager_Focus; } public Color HotkeysForeground { get { return _foregroundColor; } set { _foregroundColor = value; OnPropertyChanged(() => HotkeysForeground); } } public ReadOnlyObservableCollection<string> Hotkeys { get { return new ReadOnlyObservableCollection<string>(_hotkeys); } } public string Title { get { return _title; } set { _title = value; OnPropertyChanged(() => Title); } } protected override void OnDispose() { base.OnDispose(); _hotkeyManager.Dispose(); _focusManager.Dispose(); } private void FocusManager_Focus(object sender, FocusManagerEventArgs e) { Title = e.Title; } private void HotkeyManager_NewHotkey(object sender, EventArgs eventArgs) { HotkeysForeground = _hotkeys.Count <= 2 ? Colors.Blue : Colors.Brown; _hotkeys.Clear(); foreach (var hotkey in _hotkeyManager.GetHotkeys()) { _hotkeys.Add(hotkey); } } } } Here is the view. <Window x:Class="Monkey.View.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:System="clr-namespace:System;assembly=mscorlib" Title="{Binding Mode=OneWay, Path=Title, UpdateSourceTrigger=PropertyChanged}" Height="200" Width="200" ShowInTaskbar="False" WindowStyle="ToolWindow" Topmost="True" ResizeMode="CanResizeWithGrip" AllowsTransparency="False"> <Window.Resources> <SolidColorBrush Color="{Binding HotkeysForeground}" x:Key="HotkeysBrush"/> </Window.Resources> <ListBox Canvas.Left="110" Canvas.Top="74" Name="HotkeyList" Height="Auto" Width="Auto" HorizontalContentAlignment="Left" BorderThickness="0" ScrollViewer.CanContentScroll="False" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled" ItemsSource="{Binding Path=Hotkeys}" VerticalAlignment="Stretch" VerticalContentAlignment="Center" FontSize="20"> <ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem"> <Setter Property="IsEnabled" Value="False" /> </Style> </ListBox.ItemContainerStyle> <ListBox.ItemTemplate> <DataTemplate> <Label Content="{Binding}" Foreground="{StaticResource HotkeysBrush}"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </Window> Thank you in advance.

    Read the article

  • Confusion about WPF binding...

    - by Vladislav
    I am trying to bind a 2D array of buttons arranged in stackpanels to a 2D ObservableCollection... Yet, I'm afraid I don't understand something very elementary about binding. My XAML: <Window.Resources> <DataTemplate x:Key="ItemsAsButtons"> <Button Content="{Binding}" Height="100" Width="100"/> </DataTemplate> <DataTemplate x:Key="PanelOfPanels"> <ItemsControl ItemsSource="{Binding Path=DayNumbers}" ItemTemplate=" {DynamicResource ItemsAsButtons}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> </DataTemplate> </Window.Resources> ... <ItemsControl x:Name="DaysPanel" Grid.ColumnSpan="7" Grid.Row="2" ItemTemplate="{DynamicResource PanelOfPanels}"/> My C# code: The backend: /// <summary> /// Window BE for Calendar.xaml /// </summary> public partial class Calendar : Window { private CalendarViewModel _vm; public Calendar() { InitializeComponent(); _vm = new CalendarViewModel(); this.DataContext = _vm; } } The ViewModel: class CalendarViewModel { CalendarMonth _displayedMonth; EventCalendar _calendar; public CalendarViewModel() { _displayedMonth = new CalendarMonth(); } public ObservableCollection<ObservableCollection<int>> DayNumbers { get { return _displayedMonth.DayNumbers; } } } I'm trying to populate the buttons with values from CalendarViewModel.DayNumbers - yet the buttons do not appear. I'm clearly doing something wrong with my binding.

    Read the article

  • What is the best approach to binding commands in a ViewModel to elements in the View?

    - by Micah
    Anyone who has tried to implement RoutedCommands in WPF using M-V-VM has undoubtedly run into issues. Commands (non-UI commands that is) should be implemented in the ViewModel. For instance if I needed to save a CustomerViewModel then I would implement that as a command directly on my CustomerViewModel. However if I wanted to pop up a window to show the users addresses I would implement a ShowCustomerAddress command directly in the view since this a UI specific function. How do I define the command bindings in the viewmodel, and use them in the view?

    Read the article

  • Wpf binding with nested properties

    - by byte
    ViewModel I have a property of type Member called KeyMember. The 'Member' type has an ObservableCollection called Addresses. The Address is composed of two strings - street and postcode . View I have a ListBox whose item source need to be set to ViewModels's KeyMember property and it should display the Street of all the Past Addresses in the collection. Question My ViewModel and View relationship is established properly. I am able to write a data template for the above simple case as below <ListBox ItemsSource="{Binding KeyMember.Addresses}"> <ListBox.ItemTemplate> <DataTemplate DataType="Address"> <TextBlock Text="{Binding Street}"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox> How would I write the DataTemplate if I change KeyMember from type Member to ObservableCollection< Member assuming that the collection has only one element. PS: I know that for multiple elements in collection, I will have to implement the Master-Detail pattern/scenario.

    Read the article

< Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >