|
Thanks Meshack Musundi, it worked.
|
|
|
|
|
Thanks Meshack Musundi, nice approach. Its working fine.
|
|
|
|
|
Hi,
Currently I am facing problem in List View that, when we re-size the GridViewColumnHeader to the leftmost(width =0),not able to enlarge that column.It's not accessible later.I want to do this functionality as same as DataGrid. In DataGrid, it wont allow user to resize the column to width zero.
How can we acheive this functionality in ListView?
Thanks
|
|
|
|
|
I guess, the best way to do this would be to use the retemplating technique described here[^].
|
|
|
|
|
Just an FYI to the OP (and POH), I implemented MinWidth and MaxWidth on my own custom ListView and while the guys over at SO say "it works", I can tell you from personal experience it is an incomplete solution . There are a lot of little nuances you have to handle that the posted solution does not.
Beyond just dragging the splitter around, there is also the splitter double-click column auto-size behavior that needs to be patched, dragging columns (re-ordering) around screws things up, and the one that took me quite a while to solve: in a specific usage scenario (I forget the exact details since it's been a while), but it was something like where if you had the columns big enough so you had a horizontal scroll bar, and then did the column resize / auto-resize so it shrunk down the columns to where the scroll bar went away, the ListViewItems would not be resized properly and the control rendering would get all messed up.
This feature was actually a real PITA to get working properly in all cases. It ended up being several HUNDRED lines of code.
|
|
|
|
|
Hi, please help me regards hiding and showing stackpannel from ViewModel.
|
|
|
|
|
The standard way to do this is to expose a boolean property from your ViewModel that indicates whether or not the items the StackPanel represents are visible or not (I have worded this carefully so that you don't get the idea that the boolean maps to the StackPanel in anyway). This property must raise the PropertyChanged event when it changes. Then, in your View, bind the StackPanel Visibility to this property; as you are aware, the Visibility property is not a boolean property, so you use the BooleanToVisibilityConverter[^] to convert between the boolean value and the Visibility of the object.
|
|
|
|
|
Can you please provide any code related to this
|
|
|
|
|
I have to assume you know how to add the code into your ViewModel, so it looks like the bit that you are confused about is what happens in the XAML. Well, in your user control, add the following into the UserControl.Resources section:
<BooleanToVisibilityConverter x:Key="booleanVisibilityConverter"> Then, in your StackPanel add this (assuming that your VM property is called ShouldShow)
<StackPanel Visibility="{Binding ShouldShow, Converter={StaticResource booleanVisibilityConverter}}"
|
|
|
|
|
If you are gonna do that, you might as well just expose a Visibility property from the VM and cut out the middle man. EDIT: unless that bool would be used for various things besides visibility I mean .
|
|
|
|
|
There's an implication there, though, that your testing code is going to bring in a reference to System.Windows for something that really isn't needed. The converter method keeps your VM test code 100% plain POCO with no WPF dependency.
|
|
|
|
|
But in reality the property shouldn't be called "ShouldShow" but "IsOverseasTransaction" (or whatever business rule the View is using to determine visibility.
MVVM # - I did it My Way
___________________________________________
Man, you're a god. - walterhevedeich 26/05/2011
.\\axxx
(That's an 'M')
|
|
|
|
|
Hi, I have just started working on MVVM, MVVM is new for me, this stackpanel visibility i have to show/hide on button command. Can you please provide any idea how to show/hide on button command from view model.
Thanks Pete O'Hanlon.
|
|
|
|
|
I already have. All the pieces are there. You hook up a command - you set the boolean property and then you raise the PropertyChanged event. As long as you have this view model hooked up to your DataContext, and you use the XAML I showed, you should be good to go.
|
|
|
|
|
Thanks Pete O'Hanlon, its working perfectly.
|
|
|
|
|
Hi,
How to send the content of a button from view to ViewModel on click command.
|
|
|
|
|
DO you have some code you have tried?
|
|
|
|
|
Thanks for reply. No sorry i dont have any code right now, i have only button click command code.
can you give any solution.
|
|
|
|
|
You should try and code something up and then ask why it isnt working. We can tell you what your problems are, but youll have to do the work yourself, deal?
|
|
|
|
|
When you bind the command add a CommandParameter, this is picked up as an object in the VM method you bind to.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
yes its working, thanks Mycroft Holmes.... 
|
|
|
|
|
This sounds incorrect. Can you show some code?
You would want to pass the context of the view to the view model.
|
|
|
|
|
Abhinav, I got the solutions, thanks for showing interest.
you asked for code, so i am displaying here:
Text = {Binding Command} CommandParameter="{Binding ElementName=btn1, Path=Content}"
|
|
|
|
|
I am trying to show a chart control in my application where the chart value comes at runtime. To imitate that I tried adding a chart control and populate value on button click, but every time I try to do so error: "No suitable axis is available for plotting the dependent value"
My XAML looks like this:
<chartingToolkit:Chart Name="chart1" Height="603" VerticalAlignment="Top">
<chartingToolkit:Chart.Axes>
<chartingToolkit:LinearAxis Orientation="Y" Interval="" ></chartingToolkit:LinearAxis>
</chartingToolkit:Chart.Axes>
<chartingToolkit:LineSeries DependentValuePath="Value" IndependentValuePath="Key" ItemsSource="{Binding}" />
</chartingToolkit:Chart>
in code behind I have created following class to hold data:
public class ChartData
{
public ChartData(string key, double val)
{
Key = key;
Value = val;
}
public string Key;
public double Value;
}
Also I created an ObservableCollection of this class. Now on every button click I add certain data to this collection and at the load method of page I set the datacontext of chart to this observable collection.
I tried a lot but the error won't go.
Any help is appreciated.
Thanks in advace.
|
|
|
|
|