|
Thank you all guys, only now did I get the time to read all posts. To summarize what I learned:
1) .NET ships with IEditableObject interface which I am advised to implement in such situations
2) the implementation may use reflection, expression trees (not sure I quite understand this), or can be manually typed out for a particular class
3) the implementation (in any case) does nothing other that store a copy of the data for possible rollback later
4) .NET framework itself provides no extra advantage of using IEditableObject (except data grid and maybe few other specific controls) - a typical window with textboxes and checkboxes for data is unaware of IEditableObject and I must manually call BeginEdit, CancelEdit etc.
Therefore - if I just make the copy but not as an implementation of IEditableObject, it'll work the same, but it is not advisable because it is not standard practice.
Let me please know if I understand this correctly.
H.
|
|
|
|
|
Basically, that's spot on. Although it also ships with IEditableCollectionView which you may want to take advantage off if you are adding to collections.
|
|
|
|
|
That is kind of disappointing. Because really - the easy solution would be this: bind data model->controls only once. Do not bind back until said so (ie - user clicks OK). Maybe this would stand in the way of other things like validation, I don't know, but still I would expect that .net framework comes a bit more prepared for this very common scenario other than provide an interface any kid could write and let programmers worry about the rest.
Anyway, thanks for helping me understand this.
|
|
|
|
|
Did you download and try the sample in my blog entry? Basically I created a couple of reusable classes in there that you can just use in your project without needing to reinvent any wheels.
|
|
|
|
|
I got to give you 5 as this is exactly the approach I used (before I ran across IEditable). I copy the object in the selected property change and bind the editable## to the UI. Chucked the copy method in the ViewModelBase and never even think about it again!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I'm going to put my head on the block here and say that reflection works fine because while it's not the fastest solution, this tends not to matter to the user because this is not an operation they are going to be performing 1000s of times a second. That's why my solution uses reflection - it's easy to implement, easy to understand and conforms to the interfaces that WPF expects to see.
|
|
|
|
|
With silverlight4, how can i call the client program in web application? Only use Out-of-Brower, any other way?
|
|
|
|
|
What client application? Where is it running?
|
|
|
|
|
Dear Abby,
I have a bitmap that I am displaying on an Expander header.
<Image Source="{Binding TaskType, Converter={StaticResource ImageConverter}}" />
using the following ValueConverter
public object Convert(object value, Type targetType,
object parameter, CultureInfo culture)
{
System.Drawing.Image img = global::ToDoManager.Properties.Resources.Pencil;
var bitmap = new System.Windows.Media.Imaging.BitmapImage();
bitmap.BeginInit();
MemoryStream stream = new MemoryStream();
img.Save(stream, ImageFormat.Bmp);
stream.Seek(0, SeekOrigin.Begin);
bitmap.StreamSource = stream;
bitmap.EndInit();
stream.Dispose();
return bitmap;
}
which is working except that the transparent area is black. I guess I need something, encoder maybe to preserve
the transparency. It's like when I'm creating the new BitmapImage it creates it without an Alpha channel.
I've googled but everything I've found leads to this solution and people admit there's a problem but no one
has offered a solution.
Jangled in Jacksonville
C'est What?
|
|
|
|
|
|
Not really, as that's not for a WPF Bitmap.
|
|
|
|
|
Good point well put - didn't notice that!
This one[^] talks about using GDI+ in combination with WFP to get alpha channels
C# has already designed away most of the tedium of C++.
|
|
|
|
|
Funnily enough, I've just posted a variant of that.
|
|
|
|
|
NO the link was no help because the converter converts from a Bitmap to a BitmapImage.
The reason you have to convert is that WPF uses the Bitmap image to take advantage of
the underlying DirectX.
But hanks for the effort.
Sects Therapy
|
|
|
|
|
If you're happy to use GDI+ as an intermediate step, you can get round this with something like:
public static BitmapSource MakeTransparent(this MemoryStream stream)
{
Bitmap bitmap = new Bitmap(stream);
bitmap.MakeTransparent();
return Imaging.CreateBitmapSourceFromHBitmap(
bitmap.GetHBitmap(),
IntPtr.Zero,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions()
);
}
|
|
|
|
|
I saw that solution in a couple of places but was hoping not to get my hands to dirty.
Also I'm afraid of performance issues as I'm trying to put an image in a DataGridView column where the application
is an VS2010 extension here[^] that I'm trying to add functionality. It's not a gotta have but thought it might enhance the
touchy-feely.
Thanks I'll give a shot and see how it works.
[update]
Worked like a charm but there was a gotcha;
1) Had to put it inline because I'm using in a ValueConverter it complained about it not being static then
when I made static it complained something about class needed to be non-generic???
var bitmap = new System.Windows.Media.Imaging.BitmapImage();
MemoryStream stream = new MemoryStream();
img.Save(stream, ImageFormat.Bmp);
stream.Seek(0, SeekOrigin.Begin);
bitmap.StreamSource = stream;
Bitmap bitmap1 = new Bitmap(stream);
bitmap1.MakeTransparent();
return Imaging.CreateBitmapSourceFromHBitmap(
bitmap1.GetHbitmap(),
IntPtr.Zero,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions()
);
Thanks for the tip.
Sects Therapy
modified on Monday, September 5, 2011 4:27 PM
|
|
|
|
|
Great job there. Glad you have it working.
|
|
|
|
|
hello,
I am new to WPF, and i have the task to navigate between xaml files. the scenario is:
I use an external IDE "Aurora" from mobiform, which has loose xaml files, i want to implement hyperlink to move between different files via xaml
Thanks In Advance
ali
|
|
|
|
|
Navigation Overview[^] explains about browser style navigation that you can use in WPF.
It should be ideal for the scenario you are looking for.
Here[^] is another useful link on the Page Navigation framework.
Too much of heaven can bring you underground
Heaven can always turn around
Too much of heaven, our life is all hell bound
Heaven, the kill that makes no sound
|
|
|
|
|
I have installed the visual web developer 2010 on windows 7 pro 64 bit machine.
In control panel, I can see that this has been installed but I do not see a link to it in All Programs menu and so I do not know how to start it?
Can you suggest a way to solve this issue please?
Thanks
|
|
|
|
|
First of all, this is the wrong forum.
You would do better to post this question in the Visual Studio forum.
Try going to the place where Visual Studio was installed (probably C:\Program Files\Microsoft Visual Studio Express\Common7\IDE) and launch devenv.exe from there.
If you can get to the Visual Studio command prompt, you can launch the IDE from there as well.
Just go to the installation path and then type in Devenv in the window.
Too much of heaven can bring you underground
Heaven can always turn around
Too much of heaven, our life is all hell bound
Heaven, the kill that makes no sound
|
|
|
|
|
|
You are welcome.
Too much of heaven can bring you underground
Heaven can always turn around
Too much of heaven, our life is all hell bound
Heaven, the kill that makes no sound
|
|
|
|
|
This is fairly common. You need to update your service pack. Poll for a windows update and you should have your link.
if you browse to the exe location and double click the exe, you'll get a message telling you to install service pack before you can use the software
|
|
|
|
|
Hi,
I Have one question...
i have parent window and child window..
in parent window i opened child window and in child window am playing selected multiple songs from the list box so i want to apply those selected songs as background music to the parent window ..
how? and what should i do ?
please help me..
thanks in advance.
|
|
|
|