|
|
In addition to the article above, which is pretty much the MVVM standard, it seems, I would like to stress that you should take a long hard look at commands, templates and databinding before writing any code. Josh Smith's article uses commands in a different way from some others. This[^] article has IMO a nicer way of managing commands. Also, this[^] is a nice cheatsheet for WPF databinding.
|
|
|
|
|
I am looking for a small example in MVVM pattern.
I should be able to add data to the database and display data from the database
using MVVM pattern
If you have any thing like that send me or please post a link to it.
|
|
|
|
|
|
I have a simple UI I'm trying to write using the MVVM pattern:
Click a "browse" button, the OpenFileDialog should show up, let the user select a file, and then the "selected file" textbox should be filled with the selected file.
How do you do this simple thing in MVVM?
Religiously blogging on the intarwebs since the early 21st century: Kineti L'Tziyon
Judah Himango
|
|
|
|
|
Have a look at Onyx[^]. This has this functionality all built in for you.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Awesome, thanks Pete.
Religiously blogging on the intarwebs since the early 21st century: Kineti L'Tziyon
Judah Himango
|
|
|
|
|
No probs mate.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
how I can creat or use a plotter(osciloscope) in my project(wpf)?
|
|
|
|
|
Please use a better title than Wpf - we know that this forum is WPF, and we don't need you to tell us that. Use the title to give us an indication of what your problem is, other than an inability to come up with a working title.
miralireza wrote: how I can creat or use a plotter(osciloscope) in my project(wpf)?
You're probably going to need the API for your Oscilloscope. This isn't a WPF specific question - it's more about how you interface with an external system. Your use of WPF is a secondary consideration.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
HI, This is a simple one, but i cant get it to work
I have a combobox filled with color names and a small colored rectangle next to the names.
I want to bind this combobox to a text box, such that when a color is selected in combobox, only the color name shows up in the text box. I need to do this programatically, not in xaml
My combobox datatemplate is
<DataTemplate x:Key="ColorText" >
<StackPanel Orientation="Horizontal">
<Rectangle Width="20" Height="28" Fill="{Binding Name}" Stroke="#FF000000"/>
<TextBlock Text ="{Binding Name}" />
</StackPanel>
</DataTemplate>
My current code to bind is
Binding myBinding = new Binding("Text");
myBinding.Source = this.colorTextBox;
myBinding.Mode = BindingMode.Default;
this.comboBox.SetBinding(ComboBox.SelectedItemProperty, myBinding);
But the result i get in text box is "System.Windows.Media.Color Blue" , i need only Blue to appear in the text box.
comboBox.selectedItem object contains 2 types, one is color and other is Name as the datatemplate shows.
Please help me to modify my above binding code , such that the text box shows only the name of the color and not "System.Windows.Media.Color Blue".
These controls(combobox and textbox) are programatically generated.
|
|
|
|
|
Use a converter.
Create a class that implements IValueConverter, and in the Convert() function, change it from "System.Windows.Media.Color.Blue" to "Blue" with some simple string parsing. Then just set it as the Converter property of the binding.
Your code is a bit confusing, though... You're binding the selected item to a textbox? Does the Name property contain an actual color object, or a name of a color? Something doesn't seem quite right.
|
|
|
|
|
The name property contains only a string eg. "Blue"
The comboBox is filled with colors from Colors list.
Helper h=new Helper();
this.comboBox.ItemsSource =h.GetPropNames(typeof(Colors));
The first property is a color and second one is Name, hence the full string looks like this "System.Windows.Media.Color.Blue Blue". I want to bind the comboBox.selectedItem.Name to the textbox, so the textbox shows only "Blue"
I used value converters and it works , Thank you
|
|
|
|
|
Dear Friends,
See I want to Clear My IsolateStorage once the Browser is Closed In Silverlight.
I Have I Tried with Evry Javascript Posssible.I Dont Wnat to Clear my Isolated
Storage When Browser is Refreshed.So How Should I Detech Browser Closed
And Refres.
Thanks in Advance.
Regards,
Muneer.
Muneer
|
|
|
|
|
How can we capture the Keypress event and the pressed key, on a WPF toolkit datagrid? I need to capture the F9 key, when the user is focussed on a particular column.
Plus, can anybody suggest a good site to study the WPF toolkit datagrid? The basic CRUD operations need to be implemented. I am totally new to .NET 3.5.
Thanks Folks!!!
|
|
|
|
|
I'm having a similar problem; I need to implement a double-click on the datagrid, while using MVVM. So I don't want to have any event handling code in the code-behind. Preferably binding to a command property in the VM.
I've searched the internet all ower and still cannot find a suitable solution. Is there somehow a way (for me and sameercodes) to handle these keyboard and mouse events with behaviours or gestures AND bind to a command
Thanks.
|
|
|
|
|
To learn about DataGrid, I suggest looking at "WPF DataGrid Practical Examples" [^]. To respond to the F9 key I expect you can use the KeyDown event, but I have not tried this.
To handle such events in a MVVM pattern - that is tricky and not something I have solved. So far I have taken the easy path and simply used codebehind. I suspect the answer might be in "WPF : If Heineken did MVVM Frameworks Part 2 of n" [^] - View Lifecycle Events - but I have not yet properly followed this or tried it.
I hope that might be helpful.
Tim
|
|
|
|
|
Hi,
I have a WPF custom control. Its a container control derived from system.Windows.controls.Grid.
My requirement is only one control should be there in a cell of Grid.
I want to delete a control say Button, when the user drags & drops it on my custom control's cell & that cell already contains a control in it. I want to delete the control automatically & also the XAML should be updated for the same(XAML entry for the control should also be removed).
Currently what I am doing is in my Custom container's ArrangeOverride Method(), I am deleting the child control but the XAML is not updated for the same. I mean when the control is dragged on a cell with already having a control, control doen't appear in UI(as the code in ArrangeOverride deletes it from child collection ) but the XAML entry for the control is still present in xaml.
should I use any AdonerProvider or TaskProvider fotr this. If so how?
Thanks in Advance,
Vinod C S
modified on Thursday, October 22, 2009 5:18 AM
|
|
|
|
|
I have posted the following question on codeplex, but not had any reply. I am hoping someone here may be able to help.
I have a WPF DataGrid which represents a small number of options (ie one option per row), one of which is chosen as the default. In the first column of the DataGrid I want to have a RadioButton in each row - to set the default. I have almost got this to work with the code below - the Binding is working. The problem is, it is possible to get into a scenario where the setting from the RadioButton is lost.
Our underlying object being bound to implements IEditableObject and we use this in various way to check edits and also take action when the default is changed. I have found that clicking the RadioButton completely bypasses the BeginEdit / EndEdit process of the DataGrid.
The xaml is as follows:
<toolkit:DataGrid Name="dgTesters" AutoGenerateColumns="False" AlternationCount="2" ItemsSource="{Binding LocalTesters}"
CanUserAddRows="false" CanUserDeleteRows="False"
SelectionMode="Single"
RowEditEnding="dgTesters_RowEditEnding">
<toolkit:DataGrid.Columns>
<toolkit:DataGridTemplateColumn>
<toolkit:DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate >
<RadioButton IsChecked="{Binding Path=IsDefault, Mode=TwoWay}" GroupName="a" />
</DataTemplate>
</toolkit:DataGridTemplateColumn.CellEditingTemplate>
<toolkit:DataGridTemplateColumn.CellTemplate>
<DataTemplate >
<RadioButton IsChecked="{Binding Path=IsDefault, Mode=TwoWay}" GroupName="a" />
</DataTemplate>
</toolkit:DataGridTemplateColumn.CellTemplate>
</toolkit:DataGridTemplateColumn>
<toolkit:DataGridTextColumn Binding="{Binding TesterName}" Header="Tester Name" Width="*" MinWidth="80" />
<!-- Further columns deleted -->
</toolkit:DataGrid.Columns>
</toolkit:DataGrid>
I think what is happening is that the CellTemplate is handling the RadioButton click, so the CellEditingTemplate never gets to fire BeginEdit... Does that make sense?
If I remove the DataGridTemplateColumn.CellTemplate, I can see the BeginEdit / EndEdit being fired.
This is also being used in a MVVM pattern, so I wanted to avoid handling mouseclicks.
It seems using a RadioButton in this way would be a fairly common requirement - I must be missing something. Can anyone point me in the right direction?
Thanks, Tim
|
|
|
|
|
Try using Mode=OneWay in the CellTemplate and Mode=TwoWay in the
CellEditingTemplate
|
|
|
|
|
Has anyone been able to make a Silverlight socket policy server work with port forwarding? I really don't want to put the computer in the DMZ, ports 80/443 seem to forward but my policy server seems not to work even when the 943 port is forwarded
|
|
|
|
|
fred_ wrote: my policy server seems not to work even when the 943 port is forwarded
What about the actual connection port (4502-4534)....is that being forwarded?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
that works fine. Everything works until Silverlight makes the policy request to open a socket. On my home network works fine. Just won't work from an outside IP
|
|
|
|
|
Sorry if these questions are obvious, but I have to ask...
Does your policy server code ever get hit from outside?
If not, is there a firewall blocking port 943?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
firewall off for test nope seems to hit
|
|
|
|