|
Excellent,with observablecollection its working. Thanks a ton for guiding me!!!
|
|
|
|
|
Just because i thought it will help me in future. If we fetch data from some table in database, into a observable collection.
And then display that data in the grid.
When the user edits the grid, changes are reflected in observable collection, is there a quick way to commit those changes in the database as well??
|
|
|
|
|
I don't really know, to be honest. I've not done any database work with WPF yet, that is nothing to a SQL database, all to my own file formats. I would imagine you'd want to make an observablecollection of a class type, and write code in there to update the DB if data is changed, or new data added, but that could be old school thought, there may be something better built in.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
I have the same feeling,there must be a better way of doing it. Thanks for your help though!
|
|
|
|
|
Any time you add an item into an observable collection, or remove an item, the collection raises a CollectionChanged event. You can use this to identify records that have been added or deleted. If you are updating a record though, the collection won't help you because it doesn't monitor changes to items in the collection; it only monitors changes to the collection itself.
What you need to do, in this case, is have your model expose INotifyPropertyChanged, and then (whenever a property is changed), raise a change notification on the item itself. This[^] article gives a bit more detail about notifications.
"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
|
|
|
|
|
See - I knew there was a smarter answer....
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hi
I have a startup form in my app. When this form loads the main form in the background is blurred out using a BitmapEffect and a timer. The timer is used to increment the blur radius in every timer tick, and then un-blur the screen again using another timer.
What I want to know is, is there a better way of gradually blurring the form in the background without using a timer each time?
Below is a sample of the code I'm using.
void blurTimer_Tick(object sender, EventArgs e)
{
if (blurTimerCount != 10)
{
BlurBitmapEffect blurEffect = new BlurBitmapEffect();
blurEffect.Radius = blurTimerCount;
blurEffect.KernelType = KernelType.Box;
mainWindow.BitmapEffect = blurEffect;
blurTimerCount++;
}
if (blurTimerCount == 10)
{
blurTimer.Stop();
}
}
|
|
|
|
|
Setup a storyboard somehow, and "animate" it?
I was thinking about trying that myself.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Etienne_123 wrote: blurEffect.Radius = blurTimerCount;
This looks like the property you could just animate in a timeline in XAML, to me.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
This is actually quite trivial. Here's a sample:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Window.BitmapEffect>
<BlurBitmapEffect x:Name="blurTarget" KernelType="Gaussian" Radius="0"/>
</Window.BitmapEffect>
<Window.Triggers>
<EventTrigger RoutedEvent="Window.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Duration="0: 0:10"
From="0.0"
Storyboard.TargetName="blurTarget"
Storyboard.TargetProperty="Radius"
To="40.0"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Window.Triggers>
<Grid>
<Button Content="This Is my button" />
</Grid>
</Window>
"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
|
|
|
|
|
Thanks guys, I got it working.
I just declared 2 new storyboards in my xaml (one for blurring and another for unblurring), then I just used the following in the code behind to start the storyboards:
Storyboard storyBlur = this.FindResource("blurMainWindow") as Storyboard;
storyBlur.Begin();
|
|
|
|
|
I tried this:
<BlurEffect x:Name="blurTarget" Radius="12" KernelType="Gaussian" />
<Storyboard x:Key="AnimateUnblur">
<DoubleAnimation From="12" To="0" Duration="0:0:1"
Storyboard.TargetName="blurTarget"
Storyboard.TargetProperty="Radius" />
</Storyboard>
and then tried this:
BlurEffect blur = (BlurEffect)FindResource("blurTarget");
this.Effect = blur;
And it's throwing an exception because it can't find the resource "blurTarget".
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I'm using page navigation, with pack URI's specified like this:
Uri uri = new Uri(@"/DetailAssembly;component/Detail.xaml",UriKind.Relative);
frame.Navigate(uri); In the LoadCompleted handler, I see the following:
public void _DetailLoadCompleted(Object sender,NavigationEventArgs e)
{
} Somewhere along the line, someone removed the leading '/' character from the relative URI.
I know this is a picayune little detail, but does anyone know why they would do this? I thought maybe there was something I'm not understanding about URI's in WPF, but I can't find anything on MSDN or in my books. My basic conclusion is that it's just a bug. Can anyone offer any other explanation?
Software Zen: delete this;
|
|
|
|
|
Hi,
I am writing WPF custom control. My problem is I want to do some updations in the control when the control is being creted by copy paste( CTRL+C, CTRL+V) on the cider.
How can I track this event or attch an handler to this event.
Does ApplicationCommand.copy.... make any sense here.
Please help.
Thanks in Advance,
Vinod
|
|
|
|
|
You mean when it gets added to a form in the designer ? I'm not sure how you write event code in your control, for an event that fires in another program, but I suspect if it can be done, it will be an actual event that's called by the IDE, OR the constructor is called and you can write a block of code that detects if you're in the designer ( this can be done in Winforms, for sure )
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
You'll need to write a designer for your control. This is not trival.
You can search for WPF control designer for examples.
There is also documentation on MDSN.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Hi,
I am working on a WPF application. In this we will change the position of the components on the canvas. Every time we change the positions of the components on the canvas, we have to display a thumbnails of the canvas.
I have a procedure to create the images of the canvas.
http://blogs.msdn.com/saveenr/archive/2008/09/18/wpf-xaml-saving-a-window-or-canvas-as-a-png-bitmap.aspx
Now I have to display the images of the thumbnail as canvas dynamically as thumbnails.
If anyone have any idea to solve this please reply me.
Thanks in Advance
|
|
|
|
|
You might want to use a variation of this[^].
"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,
In WPF, I can set Image with a photo, and can see when I load the page. However, if I want to set that through a code-behind, I cannot. Here is my code, do you find anything wrong in it that might cause this problem? I checked on compile time, and there is no problem in the location of myPhoto.png.
> string location = @"C:\myPhoto.png";
> Uri uri= new Uri(location,> UriKind.Relative);
> ImageSource imgSource = new BitmapImage(uri);
> Icons.Source = imgSource;
> Icons.Width = 10;
>Icons.Height = 10;
> Icons.Visibility = Visibility.Visible;
thanks,
|
|
|
|
|
Maybe try
C:/ myPhoto.png
Or
File://C:/myPhoto.png
The UriKind should be Absolute as well.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: The UriKind should be Absolute as well.
When I made that mistake, I remember getting a compiler error. I was using "/AssemblyName;component/Images/filename.png", and still had to use Absolute.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
That's an absolute address though, isn't it?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I wouldn't think so. I would think an absolute address would be a fully qualified path, and the one I use would be relative to the named assembly.
I guess it's a matter of perception.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
paradisonoir wrote: > string location = @"C:\myPhoto.png";
> Uri uri= new Uri(location,> UriKind.Relative);
That's an absolute path, not a relative one.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hey! I'm working this side of the street
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|