Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I have a View - which is a UserControl - that shows different information and gets updated by its corresponding ViewModel.
Now I want to use this View in different other Views, which are UserControls as well.
I tried different approaches like using ResourceDictionaries and other stuff, but I couldnĀ“t get a satisfying result.
You have to put a ContentControl in views that are importing your view and set the ContentControl's Content to the given view
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
Actually i'm developing new asp.net mvc app in most like qustionare. But while developing i came across an issue. I created action method which renders questions one by one depending on passed questionId. So when i try to render next question, my Html.CheckBoxFor somehow remember state of previous question and just left the same state independently from real value.
Does anybody experienced such error?
Thanks
In your Post action, try clearing the model and then using ModelState.Clear() before passing it to the view again.
Validation information and model bindings are kept when posting back from an [HTTPPost] action unless you clear the model's state. I think there is an assumption in MVC you would only post back to show validation messages and allow changes. If that's not the case then use ModelState.Clear() and reset your values. see link below...
Why you need ModelState.Clear
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I want to navigate from main window to other user control which is present in the views folder. I am not using mvvm model. Is it possible to navigate
Seems that question you asked is not complete, but I'll try to answer.
So you have window, and some content inside of it, and that's MainWindow i suppose. You want to change content of main window to contain your user control which is also defined in separate file. So, you can't do this in the way you described.
UserControl is only a control that window can contain, so basicaly you need something like placeholder in your window to change content dynamically like web browser navigation, and that's what Frame is.
Frame is control that helps to provide navigation between pages. You can create Frame inside your MainWindow and also create some pages. Then you will be able to implement switching between pages in your frame using Frame.Navigate() method.
Here is similar question described, please take look:
Window vs Page vs UserControl for WPF navigation?
Also there is a good article that may help you:
http://paulstovell.com/blog/wpf-navigation
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
My MVC application currently has an Html.Begin form in order to submit a form. Now there is a nested BeginForm in order to display the radiobuttonlist. My issue is when I hit Save, it doesn't hit my HttpPost action method. How can I solve this problem?
Thanks.
While you might be able to do stuff like this in Angular, you can't do this for server-side forms. You can have more than one form on a page but they can't be nested.
You'll have to remove the inner form tags and deal with both type of post in the same controller action. Create some logic that works out what button was pressed and returns an enum called something like PostAction, then in your controller you can have a section of code for each type of action.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
So I'm having trobule figuring out the best way to use the MVVM pattern while creating a WPF control dynamically within
my code. Would this even make sense or is it better to avoid the MVVM pattern all together?
If it does make sense then please share code examples of the view model.
In general, if you're using MVVM, controls will only be created "dynamically" in response to the data changing. If you have an ItemsControl bound to a collection, for example, the controls to represent the items will automatically be created for you.
If you're talking about making a custom control in general, custom controls are really "pure view", so MVVM doens't really make sense in this scenario. The main goal of creating a custom control is to build it in a way so that it can be used by code developed with MVVM, which typically means building the control with proper Dependency Properties (so data binding works properly), etc.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
How do you structure your project for ribbon based projects, when using WPF?
I use Microsoft's Ribbon control and I wonder if I should have a single
view for the main app, but two separate view models one for the ribbon
and another for the window part below the ribbon.
You are asking a very subjective question... I'm actually surprised that it hasn't been closed yet (we have many keen question closers on this site). The answer to your question of course depends on what the application does, its size, the developer's style and preference of programming, etc.
I personally just prefer to hardcode the controls into my Ribbon rather than generating them from a view model and templates. It does make the code page large, but I'd rather have that then be confused as to what goes where and when.
I generally prefer to simply have one property of type BassViewModel in my MainViewModel class and that is data bound to a ContentControl in 'the window part below the Ribbon as you call it. Then I just set this property to the relevant view model dependant upon the users' view selection in the Ribbon.