|
Hi All,
How can we make contentcontrol aligned left and stretched to the max of the remaining browser size.
Let us suppose I have a content control in which there are few other user controls are loaded. Now can I make the content control to stretch full remaining browser size and still the user control in it be left aligned.
When I make the content control left aligned, the user control is stretching within small area. If I make the control control center aligned, the user control stretching very well to the max size of the remaining size, but coming the center.
Is there any way to stretch it and still remaining as left alignment?
I am really in need please help me. Thanks in advance.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
modified 8-Nov-11 20:03pm.
|
|
|
|
|
indian143 wrote: stretched to the max of the remaining browser size.
Using "*" in the layout width or height usually does this for you.
|
|
|
|
|
Hi,
Eventhough, ContentControl is not stretching. It stretches when I put its HorizantalContentAlignment property set to stretch, but its content is displayed in the center. This is solving problem of one form but destroying the layout of all the other forms.
So I have to keep HorizantalContentAlignment=Left and HorizantalContentAlignment=Left and still I want the content control to be streched to the max width of the remaining in the browser.
I tried in the following way by using code behind, no way its listening to me. ContentControl is a stubborn control it looks . It doesnt listen to what developers says and but developers have to listen to it . Sorry for my words, but really I am frustrated .
Remember here the actual width of the column in the grid is coming perfectly matching, and I am trying to set the width of the content control to that width. Still content control is not setting its width to the width to which I am setting to.
May be I am wrong, please advice me if you find any issues in my xaml or code behind. I requesting thanks a lot in advance.
Following is the xaml
<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" ShowGridLines="True" x:Name="parentGrid">
<Grid.RowDefinitions>
<RowDefinition Height="24" />
<RowDefinition Height="*" />
<RowDefinition Height="20" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10" />
<ColumnDefinition x:Name="grid" 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 Background="Purple" x:Name="parentContentControl"
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="Left"
HorizontalAlignment="Stretch"
SizeChanged="Content_SizeChanged"/>
<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>
Following is the code behind
void Content_SizeChanged(object sender, SizeChangedEventArgs e)
{
double minWidthOfParent;
if ((parentGrid.ColumnDefinitions[1].MinWidth == null) || (parentGrid.ActualWidth==null))
{
minWidthOfParent = 744;
}
else
{
minWidthOfParent = parentGrid.ColumnDefinitions[1].ActualWidth;
}
parentContentControl.MinWidth = minWidthOfParent;
parentContentControl.Width = minWidthOfParent;
}
Thanks,
Abdul.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
modified 9-Nov-11 13:26pm.
|
|
|
|
|
I'm confused - how can an element be stretched the entire width and be centered at the same time?
I saw your code in your other post...Your grid cell had the correct "*" width setting. The cell was NOT in the left or right column, however, so you can't expect the contentcontrol to stretch to the left or right edges unless those outer columns have 0 width. I would remove all the alignment property settings and remove all margins from the controls. See how it behaves and work from there.
Mark Salsbery
|
|
|
|
|
Hi,
Yes ContentControl is center aligned and then only it will stretch to max width. If we put it to the left aligned it will not stretch to the size of the browser, even by using the code behind. I tried by using the code behind as well. But it will stretch to the size of its contents. But they dont want the change to be in all the forms, they want change should be only in parent form.
Can I make its size be max size of the browser and still be left aligned. This Silverlight is freaking tough in sizing yaar.
Dear developers, can anybody please help me, I am in really need buddy. My sprint finishes by this weekend.
Thanks,
Abdul.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
I'm in the middle of designing a WPF app that is going to have a view with a lot of information. It is a sort of Management Console for an app that we are developing.
I am envisioning some sort of tabbed interface to organize all of the various "things" that this UI has to deal with.
The model part is fairly straightforward; it is going to be accessing an SQL database with lots of different tables.
I am wondering if the "standard" way of doing things would be to create one large view model class that worked with the overall view, or if it is more appropriate to treat each tab like a separate view, with a separate view model for each? Or does that add needless complexity? Or does it even really matter?
Thanks for any advice on the matter.
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.
|
|
|
|
|
Definitely each tab should be its own view and have its own VM. There is no view for managing the tabs per se. Its more of a control that data binds to a collection of views or VMs. Typically it'll bind to a collection of VMs and you'll use DataTemplates to map a View to the VMs and the "control" will auto create the view and wire up the data context, etc. Personally though, I find that backwards as I like to launch a view and have the xaml specify what the VM is through a ViewLocator.
|
|
|
|
|
Thanks for the feedback. I'm seriously considering using DevForce A/F to help me out.
http://drc.ideablade.com/xwiki/bin/view/Documentation/devforce-caliburn[^]
[Edit:] I'm thinking that if we ever decided we needed a web interface, I could leverage the Silverlight support in the above with minimal code changes.
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.
|
|
|
|
|
I'm doing the exact same thing right now. My app has tabs, and on each tab I add & remove user controls at runtime. So it's basically "nested' views. The MainWindowViewModel is responsible for creating the view and viewmodel and handling commands.
I created a TabInfo class. The MainWindowViewModel maintians a collection of TabInfo object. I then use that to manage the tabs.
Everything makes sense in someone's mind
|
|
|
|
|
Cool. Thanks for the feedback!
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.
|
|
|
|
|
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).
|
|
|
|