|
Each tab should be a separate view / view model and you should be plugging in /removing views on demand.
There is no concept of creating one large view model that works for all views.
|
|
|
|
|
Thanks. That seems to be the general consensus. Sorry if it was a stupid question.
WE ARE DYSLEXIC OF BORG. Refutance is systile. Your a$$ will be laminated.
There are 10 kinds of people in the world: People who know binary and people who don't.
|
|
|
|
|
Tom Delany wrote: Sorry if it was a stupid question
There is no such thing as a stupid question Only stupid answers. If you are unsure, it is always better to ask.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Thanks
WE ARE DYSLEXIC OF BORG. Refutance is systile. Your a$$ will be laminated.
There are 10 kinds of people in the world: People who know binary and people who don't.
|
|
|
|
|
Tom Delany wrote: Sorry if it was a stupid question.
Nope. It was not.
|
|
|
|
|
IMHO ...
If each tab in your tabbed interface is, essentially, stand alone, and could be presented in a different way (say in a tree view, or pop-up form etc.) then you need to model that view using a view model. the fact that a particular View attached to that view model happens to sit on a tab control somewhere is 'nothing to do with' the ViewModel.
OTOH if the separation into tabs is more just a gui convenience (that is, all the tabs are necessary and inter-related) then the ViewModel should model all of the controls on all of the tabs - and the View just 'happens' to split them into tabs. Some other implementation may decide to present all of the data in one large, scrolling form, for example, still bound to the single view model.
this isn't a criticism, as I do it myself, but I believe one of the aims of using ViewModels is that you try to design the ViewModel first rather than thinking 'I want a tabbed interface' you think 'I want to perform these functions." The ViewModel contains the data to be presented/updated, and offers the functionality - then you design the view to be able to provide the interface to the user.
So in the case of the 'Management Console' style, i would think you would have several ViewModels, one for each piece of functionality, and a ManagementConsoleViewmodel that has, as properties, each of the view models it requires to perform its functionality.
The View that binds to the 'big' view model may place the smaller views on tabs, in trees, or on the sides of an animated 3D spinning cube - by binding to its view model it has access to all it needs regardless, and each of the smaller viewmodels can also be viewed in whatever way you want - and indeed can also be used independently if required.
|
|
|
|
|
Sorry for the slow reply. My father passed away on the date that you sent this to me and I had to leave town suddenly.
Thank you for the advice. I appreciate it.
I do not in fact take your comments as criticism. In actuality, I have been trying to code up the view models first, but in parallel I have also been trying to get some idea what the view will end up looking like. As you say, it may indeed end up looking completely different that a tabbed interface. If I construct the view models properly (and that's a big if), I should be able to swap in any sort of views that I desire with minimal fuss.
WE ARE DYSLEXIC OF BORG. Refutance is systile. Your a$$ will be laminated.
There are 10 kinds of people in the world: People who know binary and people who don't.
|
|
|
|
|
Tom Delany wrote: My father passed away on the date that you sent this to me and I had to leave town suddenly.
My sympathies - not a good time.
Tom Delany wrote: If I construct the view models properly (and that's a big if),
yes - that's the problem I faced many times! I actually split my ViewModel and ViewData into separate classes - as I find this makes more sense (to me, anyway!) so my model really models the functionality to be presented, and the data is just the data that allows that functionality to occur. It allowed me more flexiblity to do what I wanted to do but it may not suit you!
Cheers
|
|
|
|
|
What is the easiest way to get a button (acting like a normal Button) with a small arrow symbol or something on the right side and when the arrow is clicked, a submenu (ContextMenu) si displayed. This is fairly common espacially in toolbars and such, see for example "New Project" button in the Visual studio toolbar.
I know I can probably get the job done with extensive templating but I want to code as little as possible and loose as little as possible of the default button behavior (mouse over effects implied by windows theme and such).
Thanks for sugegstions.
|
|
|
|
|
|
Thanks, I tried googling it but never tought of the term "split button".
|
|
|
|
|
Hello,
I created a DLL that is loaded by some host application using the MAF technology.The DLL it self uses some asembly.
Every thing goes fine, i activiate the DLL from my host aplication and when i try to use some DLL's function i get an exception:
"FileNotFoundException" when the file is the asembly that i use in the DLL,ive checked several times that the path of the assembly is corect.
what could be the problem?
Thanks
|
|
|
|
|
I have the basic drag and drop functionality up and running. Now I want to handle DragEnter and/or DragOver on the drop target and in the event handler decide whether or not the drop is allowed. I thought I would do this by setting DragEventArgs.Effects property to None when the drop is not permitted but this has absolutelly no effect - mouse cursor still looks like everything is ok and indeed Drop event is fired when you drop the item. I remember that this was the way to go in windows forms, how can I conditionally diallow dropping (other that AllowDrop=false of course) in WPF?
Edited to add:
Straight from MSDN: The drop target is also able to specify what effects it intends in response to the dropped data. For example, if the drop target does not recognize the data type to be dropped, it can refuse the data by setting its allowed effects to None. It typically does this in its DragOver event handler.
So where is the problem? I am handling DropOver, settings Effects to None and yet the drop is allowed.
|
|
|
|
|
You still need to check for drop allow in the Drop event handler and generally do nothing if drop isn't allowed.
Mark Salsbery
|
|
|
|
|
Sure, but I want the standard behavior which displays the "no drop" icon (like a stop sign or something) when drop isn't allowed (meaning DragEffect is set to None). This works fine in windows forms and is even documented in WPF but for some reason doesn't work. It's not something I have to implement myself, it's internal Windows behavior, try to drag something somewhere and you'll see for yourself).
|
|
|
|
|
Hi,
the user control that is displayed within the ContentControl is coming as left justified. Is there any way that I can keep HorizontalContentAlignment="Stretch", HorizontalAlignment="Stretch" and still make the user control left justifiable. Because if I set any of the above values to "Left", it is effecting other User Controls, specially the user control is not stretching to max width of the browser.
Is there any property in content control to stretch to the max width of the browser and still, the user control within the content control be left justifiable,
<UserControl x:Class="Huron.UI.Healthcare.Configuration.Common.TaskWorkContainerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:regions="clr-namespace:Microsoft.Practices.Prism.Regions;assembly=Microsoft.Practices.Prism"
xmlns:local="clr-namespace:Huron.UI.Healthcare.Configuration.Common"
DataContext="{Binding TaskWorkContainer,Source={StaticResource ConfigSupportViewModelLocator}}">
<Grid ScrollViewer.HorizontalScrollBarVisibility="Auto">
<Grid.RowDefinitions>
<RowDefinition Height="24" />
<RowDefinition Height="*" />
<RowDefinition Height="20" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10" />
<ColumnDefinition MinWidth="744" Width="*" />
<ColumnDefinition Width="10" />
</Grid.ColumnDefinitions>
<Canvas Grid.Row="0" Grid.Column="1" >
<local:TaskWorkContainerHeaderView
Grid.Row="0" Grid.Column="1"
DataContext="{Binding Path=FormHeader}"
VerticalAlignment="Top" />
</Canvas>
<ContentControl
Margin="0,15,0,0"
Grid.Row="1" Grid.Column="1"
regions:RegionManager.RegionName="{Binding FormData.FormBodyRegionName}"
regions:RegionManager.RegionContext="{Binding FormData}"
VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch"
HorizontalAlignment="Stretch"/>
<Canvas Grid.Row="2" Grid.Column="1" >
<local:TaskWorkContainerFooterView
Grid.Row="2" Grid.Column="1"
DataContext="{Binding Path=FormFooter}"
Visibility="{Binding Path=FooterVisibility}"
VerticalAlignment="Bottom" />
</Canvas>
</Grid>
</UserControl>
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
Your content control is in a grid cell that is star sized, so can you just set the Horizontalalignment of the contentcontrol to left?
Mark Salsbery
|
|
|
|
|
Hi,
No, when I set the HorizontalContentAlignment="Left", HorizontalAlignment="Left", the user control in the content control is shrinking towrds left. There are some borders in the user control that are coming as left side shrinked, and the user control is looking not good.
When I make HorizontalContentAlignment="Stretch", HorizontalAlignment="Stretch", the user control is displayed as center aligned and looking more ugly.
Is there any way that I can keep HorizontalContentAlignment="Stretch", HorizontalAlignment="Stretch" and still make the user control in the content control left justifiable, and stretch to the remaining width of the browser and looks beautifull.
Because if I set any of the above values to "Left", it is effecting other User Controls, specially the user control is not stretching to max width of the browser.
Thanks,
Abdul
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
I have a WPF application created that during development lives as an EXE application. All works without issue as an EXE. I wish to convert that to a DLL and to call it from a mixed-mode EXE written in C++/CLI. I want to create an inherited class that inherits from the WPF class (MainWindow). I changed the target of the WPF app to that of a library. I removed the App.xml from the solution and changed the Output type to class library.
In the CLR app I create the following class:
public ref class MyInheritedForm : public WPFNameSpace::MainWindow
{
public:
MyInheritedForm ()
{
}
};
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
MyInheritedForm^ test = gcnew MyInheritedForm;
test->Show();
return 0;
}
The problem occurs in the constructor of the base class (MainWindow) in the InitializeComponent() call. The error is:
An unhandled exception of type 'System.Exception' occurred in PresentationFramework.dll
Additional information: The component 'MyInheritedForm' does not have a resource identified by the URI '/WPFNameSpce;component/mainwindow.xaml'.
I think this "MAY" be possible but clearly there are fundamental problems. Additionally, in Nishant Sivakumar's book there is an example (FirstAvalonDerived) that crashed with the same error, at the same location. Perhaps it's a VS2010 problem as I would assume the example was tested.
Can someone write back if there is a workaround solution to this. This is a huge problem for any systems that were written in WinForms and now dead-ended due to this bug in WPF.
Thanks for any help.
modified 11-Nov-11 8:17am.
|
|
|
|
|
Hello,
Im creating MdiChild window and i add to MdiChilds content user control so far so good.
But when i take another Mdichild window and i sweep it over the first one the window that i sweep with enters between the mdichild and the user control.
thanks
|
|
|
|
|
In Silverlight/WPF?
Mark Salsbery
|
|
|
|
|
Hey,
Im using WPF
This is the piece of code that initiates the MDI child:
MdiChild child = new MdiChild();
child.Title = "AddIn";
child.Content = addin.GetVisual();//returns FrameworkElement
child.Height = 200;
child.Width = 240;
child.MaximizeBox = false;
child.Resizable = true;
child.Visibility = winVis;
child.WindowState = winState;
MDIchildren.Children.Add(child);//Add MDI child to a window
Thanks.
|
|
|
|
|
I didn't know WPF had an MdiChild class...
Mark Salsbery
|
|
|
|
|
There's a reason you don't know this. It doesn't.
|
|
|
|
|
Hi
I want to add hyperlink to a Textblock from model. Here is my code...
XAML:
<ItemsControl x:Name="Items" Style="{DynamicResource ItemsControlStyle}" />
<Style x:Key="ItemsControlStyle" TargetType="{x:Type ItemsControl}">
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<Grid x:Name="grid">
-----------
<TextBlock Text="{Binding Text}" />
-----------
</Grid>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
In xaml.cs:
Items.ItemsSource = ItemsData;
In Model
ItemsData.Add(Text = <some Value>);
This works fine and display the normal text. But I want to add hyperlink to the text from the model class. I dont want to change the xaml. So how could I add hyperlink to text from Model class?
Thanks in Advance,
|
|
|
|