|
CanUserAddRows is true if DataGrid is not Readonly.
So either set CanUserAddRows or ReadOnly property to false.
"You get that on the big jobs."
|
|
|
|
|
I'm spirits to prepare the design of my application "sending emails" I look for new WPF controls that I can use them, I find some free controls and i thank you I'm still looking
|
|
|
|
|
Do you have a question?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
You can always check out the WPF toolkit[^]. This could contain some controls useful to you.
|
|
|
|
|
This feels like a really dumb question but...
I have a Model which implements OnPropertyChanged on each field in the Model
The ViewModel has an ObservableCollection and SelectedObject of the Model. SelectedObject implements OnPropertyChanged.
When the user changed data in the textbox the Model gets that change event, how do I get the event to the ViewModel vi the SelectedObject
I assume I need to bind an event in the ViewModel to the Model OnChangeEvent. Do I need to add it to each Model as it is selected and remove it as it becomes unselected?
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
In a way, yes. A simple way to do this is to use Observable.FromEvent from the Reactive Extensions.
|
|
|
|
|
Ah research just what I need on a Friday night, nah do it in the morning, me, a couple of beer and some satay are going to get to know each other. Thanks Pete.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
No problems mate. Have a beer or three for me.
|
|
|
|
|
Hi,
I want to show an image for datapoints (same image for each data point) of the scatter series.the xaml looks like this :
<UserControl.Resources>
<ImageBrush x:Key="ImageBrushStyle" ImageSource="Images\customImage.png" />
<Style x:Key="DataPointStyle1" TargetType="DVC:ScatterDataPoint">
<Setter Property="Background" Value="{StaticResource ImageBrushStyle}"/>
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DVC:ScatterDataPoint">
<Image Source="Images\customImage.png"></Image>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<DVC:Chart Canvas.Top="80" Canvas.Left="10" x:Name="mcChart_CustomSection"
Width="800" Height="400"
Background="Gray">
<DVC:Chart.Series>
<DVC:ScatterSeries Title=" SampleData"
IndependentValueBinding="{Binding Path=Key}"
DependentValueBinding="{Binding Path=Value}">
</DVC:ScatterSeries>
</DVC:Chart.Series>
</DVC:Chart>
</Grid>
</UserControl>
Then,
The code sets the style in this way :
((ScatterSeries)mcChart_CustomSection.Series[0]).ItemsSource =
new KeyValuePair<int, int>[]{
new KeyValuePair<int, int>(1, 140),
new KeyValuePair<int, int>(2, 150)
};
var ss1 = (ScatterSeries)mcChart_CustomSection.Series[0];
mcChart_CustomSection.Series.Remove(ss1);
ss1.DataPointStyle = (Style)this.Resources["DataPointStyle1"];
mcChart_CustomSection.Series.Add(ss1);
But, it does not work.(The points are not plotted).
Is it possible to show image there(Images\customImage.png)?
Thanks.
|
|
|
|
|
Any ideas?
Since, my image is going to be like a rectangle, with some text inside it, I tried to first simply use :
<Rectangle Fill="Yellow" Width="100" Height="100" />
instead
<Image Source="Images\customImage.png"></Image>
It plots the datapoint and shows rectangle, but, the rectangle shown is very small. I want to increase the size of that rectangle.(increasing Height, width does not work).
|
|
|
|
|
Hello,
I have a textBox which has binding to a property of a ViewModel.
I want the ViewModel to execute a method if the textbox is not empty and if user didn't change the text in the textbox for 2 seconds. I mean only if user wrote something and waited for 2 seconds, than the method will execute. How can i do it?
|
|
|
|
|
Have a timer in the VM
Have the onchange event in the model for the field reset the timer (and clear the cache string, possibly)
In the tick method check the content of the field if != string.empty and matches the cached string then call your method
Cache the string
Onchange of the selected item always clear the cache string
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Sounds like too much work. When he adds a 2nd edit box / timer, he'll have to copy & paste all that crap. Better solution would be to write a "TextBoxEx" control that encapsulates the behavior so it is easier to reuse and you don't have to dick around with forwarding a bunch of stuff to the VM.
|
|
|
|
|
SledgeHammer01 wrote: When he adds a 2nd edit box / timer
Only applies if this rather esoteric requirement needs to be duplicated, but yes I think I'd do with the textboxex out of good design principles (never write code twice)
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
How do you make an image NOT grow depending on the size of the picture. I'v tried all 4 Stretch values and as soon as I set the source, the image control changes size.
I want the actual size of the image control to be determined by the height & width of its grid cell. The cell's Height & Width are both Auto.
Thanks
Everything makes sense in someone's mind
modified 28-Mar-12 17:26pm.
|
|
|
|
|
That's what I thought. When I try this, the image doesn't appear
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto" Name="PictureGridRow"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" Name="PictureGridColumn" />
</Grid.ColumnDefinitions>
<Image Source="{Binding SelectedImage.Image}"
Height="{Binding ElementName=PictureGridRow, Path='ActualHeight}"
Width="{Binding ElementName=PictureGridColumn, Path='ActualWidth'}"
Grid.Row="1"
Grid.Column="0"
Stretch="None"/>
Also, I added this:
<Label Content="{Binding ElementName=PictureGridRow, Path='ActualHeight'}"
Grid.Row="0"
Grid.Column="0" />
It shows 0.
Everything makes sense in someone's mind
|
|
|
|
|
Oh... that grid. I thought you were talking about a different grid. Your issue here is that there is no content, so it doesn't know what to size it to. What size do you want the row & column to be? Everything there is auto and as such will be sized to the content.
|
|
|
|
|
This grid is to the left of a splitter, so what I'd like is a square image who's side are equal to the width of the grid. This should be the same as the Left value of the splitter.
Everything makes sense in someone's mind
|
|
|
|
|
In my opinion reason is Binding.
<Image Source="{Binding SelectedImage.Image}"
Where do you've definition SelectedImage? Example in other file than MainWindow.xaml.cs
<xlms:local="clr-namespace:ExampleXAML.ImageViewModel>
<Grid>
<Grid.DataContext>
<local:SelectedImageViewModel>
</Grid.DataContext>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto" Name="PictureGridRow"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" Name="PictureGridColumn" />
</Grid.ColumnDefinitions>
<Image Source="{Binding SelectedImage.Image}"
Height="{Binding ElementName=PictureGridRow, Path='ActualHeight}"
Width="{Binding ElementName=PictureGridColumn, Path='ActualWidth'}"
Grid.Row="1"
Grid.Column="0"
Stretch="None"/>
</Grid>
|
|
|
|
|
When you see this
ItemsSource="{Binding}"
What is this bound to?
Everything makes sense in someone's mind
|
|
|
|
|
The DataContext for that container.
|
|
|
|
|
Ya, but to which property?
Everything makes sense in someone's mind
|
|
|
|
|
|
I havn't see this syntax before. I'v always seen bindings point to a property name.
Ok, so when you have
ItemSource="{Binding}"
then the list is bound to the entire class. Then it's up to the template to bind individual elements to properties on the class.
Do I have this right?
Everything makes sense in someone's mind
|
|
|
|
|
You don't generally do that on ItemsSource since it doesn't really make sense since ItemsSource has to point to a collection. If your VM itself is a collection then it will work. Generally you use it in a template, or maybe a parameter. Its basically for when you want to point to the entire object itself. So if your items source is List<Widget>,then in the data template, {Binding} will point to the entire Widget.
|
|
|
|