|
1. Create your dbml
2. Read in some data from the database into the domain objects built by sqlmetal
3. Read that data into an ObservableCollection
4. Bind that ObservableCollection to your grid
|
|
|
|
|
Thanks again,
i will follow your way if i will meet some difficult i will create a new post to ask help.
THanks so much SqlMetal is so nice
I wish you happy day.
Bye
|
|
|
|
|
No problem.
One tip ... when using SQLMetal I generally tend to also create a batch file with the commands in so that if the database scheme changes you can be assured that recreating the LINQ context the classes will be built with the same parameters.
|
|
|
|
|
Sorry Jammer
how i can create a batch file in the project?With SqlMetal?
Thanks for your support.
Bye
|
|
|
|
|
|
Hi,
I have a WPF application. We have a requirement where in user can add/edit a document to the Share Point document library from the WPF Client application. Using Front Page RPC we are successfully able to add the documents to the Share Point document library. After successfully uploading a document to the Share Point doc. library, an entry is made in the database which stores the File Name, SP File URL etc.
To accomplish the EDIT functionality, we show a list of all the docs (from the DB) which were uploaded to the Share Point library. When user selects a file from the list & clicks on EDIT button we need to open the SharePoint file from the document library for editing. How do we open a SharePoint file for editing from a WPF client application (note: Share Point is not installed on the machine where the WPF application is used)? What's the best approach to accomplish this functionality?
Regards,
Vipul Mehta
|
|
|
|
|
I m trying to do insert,delete or update or any other data operation.
I have tried with following link
http://www.codeproject.com/KB/silverlight/crud-op-in-silverlight.aspx?display=Print[^]
but I am not getting the _mystore.SaveChanges()method when i try to do any operation (insert)
I m not getting where i m doing wrong....
Also then i have tried
_mystore.BeginSaveChanges(SaveChangesOptions.None, (asyncResult) => { _mystore.EndSaveChanges(asyncResult); },null);
in place of
_mystore.SaveChanges();
but the error occurs on this line that "An error occurred while processing this request." at
_mystore.EndSaveChanges(asyncResult); }
Can anybody suggest me some solution?
Thanks in advance,
|
|
|
|
|
There might be some changes in Astoria Data Service.
Please try to use the latest version of Astoria Data Service dll for Silverlight.
I will see if I can update all of my samples within this weekend.
|
|
|
|
|
I have tried with
_mystore.BeginSaveChanges(SaveChangesOptions.None, (asyncResult) => { _mystore.EndSaveChanges(asyncResult); },null);
in place of
_mystore.SaveChanges()
and the things worked..
Now I am happy that my data is being saved....
Thanks for ur valuable response Michael.....
|
|
|
|
|
Hello,
After much searching on MSDN and other sources I have basically found that "some" Dependancy Properties do indeed support property value inheritance similar to WPF. However, as far as I can tell, there is no definitive list of which properties do, and which do not. I know Font properties, for example, do; yet HorizontalContentAlignment does not. I have also seen the other thread in this forum which points out that the DP Precedence list does not include value inheritance (http://msdn.microsoft.com/en-us/library/cc265148(VS.95).aspx#listing[^]).
Furthermore, it seems that it is not possible to even apply Inheritable metadata to any custom DP, so it seems the silverlight framework has custom hacked it in for specific properties. I need to know exactly which dependancy properties do indeed support property value inheritance. If I have missed an obvious article on this, or a thread, then I apologize but I have been pretty thorough in my search.
Thanks.
|
|
|
|
|
I've just looked at "Get Started Building Silverlight 2 Applications" on the Silverlight site. Step 2 of the 4 is Install Expression Blend. How viable is it to learn Silverlight dev without having Expression Blend. Say I only have Visual Web Developer Express SP1? (I've not actually downloaded SP1 yet, btw.)
Kevin
|
|
|
|
|
- I'm doing it with VS 2008 only, myself...I think you have to install SP1 if you want to use Silverlight 2.0 final.
- I downloaded and installed the Blend trial, but it conflicted with my Office 2003 so I un-installed it.
- If you know Flash and are used to designing graphically, it's a little irritating not being able to click on the graphics you create in the XAML code. If you're more programmer oriented anyway, that wouldn't be a big deal.
- Some of the 'how-to' videos only show how to do it with Blend...if you were patient, you could probably get around it.
- Need Blend for keyframe-based animation if you want to do it like Flash.
So far, it's going well, so yeah, you can get by without Blend for most stuff, except keyframe-based animation
|
|
|
|
|
Thanks David, that's good to know. I'll have to install SP1 for Express. Can't afford a VS 2008 upgrade right now ("resting" contractor ).
Kevin
|
|
|
|
|
Kevin McFarlane wrote: Can't afford a VS 2008 upgrade right now ("resting" contractor ).
I hear you...freelancing/resting/learning here as well.
|
|
|
|
|
Well, I finally upgraded to SP1 at the weekend and I've been working through Scott Guthrie's tutorial. It can be a bit fiddly when you make typos and are faced with a blank screen! Do you have a Silverlight book yet? It seems that Silverlight 2 in Action is worth getting but I'll see how far I get with online resources for now.
Kevin
|
|
|
|
|
Fiddly is right Try watching some of the videos...you're trying to follow along and he's whipping through the thing...pause...play....pause...play...pause...'what was that method again?'...rewind...rewind...play...rewind...play...'oh, ya, that's it'...play...pause...play...pause. It's good negative reinforcement to make you memorize stuff, anyway
I haven't gotten a book yet...mostly sorting through the online stuff as well.
So far, I'm liking Silverlight...my only complaint is about dealing with database stuff...a technology that's supposed to be all 'open' and 'cross platform' is too Microsoft Server centric...I need a database backend for it that works on a linux.
|
|
|
|
|
Just started taking a serious look at Silverlight 2 myself, had to uninstall Blend since the evaluation expired and I don't miss it. Working with it off VS2008 Standard edition right now and all is okay.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
OK, I'll have to give it a go. Got to install SP1 for Express first though. I'm hoping that it doesn't trash my system, as it can be problematic judging from reports.
Kevin
|
|
|
|
|
Best is, when I show an example:
XAML:
<Window x:Class="WpfApplication2.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid x:Name="grid" ShowGridLines="True">
</Grid>
</Window>
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Threading;
namespace WpfApplication2
{
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
ObsCls coll = CreateObsColl();
grid.DataContext = coll;
for (int i = 0; i < 5; i++)
{
RowDefinition row = new RowDefinition();
ColumnDefinition col = new ColumnDefinition();
grid.RowDefinitions.Add(row);
grid.ColumnDefinitions.Add(col);
}
foreach (var item in coll)
{
Grid.SetColumn(item, (int)item.Content);
Grid.SetRow(item, (int)item.Content);
}
Thread t = new Thread(() =>
{
Dispatcher.BeginInvoke(new Action(() =>
{
coll.Clear();
Button b = new Button() { Content = 4 };
Grid.SetRow(b, (int)b.Content);
Grid.SetColumn(b, (int)b.Content);
coll.Add(b);
}));
});
t.Start();
}
private ObsCls CreateObsColl()
{
ObsCls coll = new ObsCls();
coll.Add(new Button() { Content = 1 });
coll.Add(new Button() { Content = 2 });
coll.Add(new Button() { Content = 3 });
return coll;
}
}
}
using System.Collections.ObjectModel;
using System.Windows.Controls;
namespace WpfApplication2
{
class ObsCls : ObservableCollection<Button>
{
}
}
What has to be done to get this working? Help would be really apreciated.
Thanks in advance
|
|
|
|
|
Scratch that last reply - you were already adding child buttons.
It looks like you're trying to use a Grid (Panel) as a DataGrid...
Are you using the right grid type?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
what would be the alternative? As long as there is no DataGrid in WPF.
After all all I want to do is displaying Buttons and Textblocks on certain Positions within a Matrix.
What I do now is cleaning the children of the grid and resetting them each time I change something. Not the best way I think, despite other problems I have with this..
|
|
|
|
|
ezazazel wrote: what would be the alternative? As long as there is no DataGrid in WPF.
There's a nice datagrid here: WPF Toolkit - October 2008 Release[^]
It's not in the .NET framework proper yet, but it's there as an add-on!
Is datagrid functionality what you are looking for or do you have controls
that dynamically change often and/or are always arranged at runtime?
I'm not sure what you're trying to do
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Ok, let's dive in deep:
I have a device where I can connect devices with other devices, a matrix.
The devices on each side send events, e.g OK and FAIL
I want to write a piece of software which has an observable collection with elements (buttons)
created by the information from the events.
This is: two devices connected (IN / OUT)
The Position inside the softwarematrix is generated from indeviceposition=>X and outdeviceposition=>Y
So in the beginning I ask all devices and generate the observablecollection.
A timer request when elapsed all devices for their status.
Let's pretend device1(IN) with device2(OUT) is connected.
This results in a button within the softwarematrix in Grid.SetRow(item, 1) and Grid.SerRow(item,2)
Now the timer requests again and this special IN/OUT combination failed, so the value ISFaulty of the observablecollectionitem is set to true and the softwarematrix displays the button now in red.
As you can see, I did it with grid.Children.Clear and grid.Children.Add when the observablecollection fires the event onCollectionChanged.
What I think is, that there should be a better way, maybe by binding the display directly to the observablecollection.
To get this to work, there need to be rules:
Rule1: PositionX and PositionY inside the softwarematrix are taken out of the properties from the class
Rule2: BackgroundColor is defined by the status of an enumeration
So that's it in short words.
|
|
|
|
|
If you have a fixed number of rows and columns in the grid, you may be able to use a generic ItemsControl with some clever styles and templates. The ItemsControl.ItemsPanel would have the grid definition, and the ItemsTemplate would have a DataTemplate that binds the Grid.Row/Column properties to the associated properties on your object. The colorings could be set using Triggers (maybe DataTrigger instead of regular Trigger) in the template based on the value of an enumeration property.
If you have a dynamic number of rows and columns, it could be done, but is much more difficult because you have to get the actual items panel for your ItemsControl instance. I am fairly certain that this is doable, but it takes a fair bit of code to pull off.
|
|
|
|
|
Actually I'm doing this:
internal class ObsCollection<T> :ObservableCollection<T>
{
private bool _suppressNotification = false;
protected override void InsertItem(int index, T item)
{
base.InsertItem(index, item);
if (item is INotifyPropertyChanged)
(item as INotifyPropertyChanged).PropertyChanged += new PropertyChangedEventHandler(ObsCollection_PropertyChanged);
}
protected override void RemoveItem(int index)
{
if (this[index] is INotifyPropertyChanged)
(this[index] as INotifyPropertyChanged).PropertyChanged -= new PropertyChangedEventHandler(ObsCollection_PropertyChanged);
base.RemoveItem(index);
}
protected override void ClearItems()
{
for (int i = 0; i < this.Count; i++)
{
RemoveItem(i);
}
}
void ObsCollection_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}
protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
{
if (!_suppressNotification)
base.OnCollectionChanged(e);
}
public void AddRange(IEnumerable<T> list)
{
if (list == null)
throw new ArgumentNullException("list");
_suppressNotification = true;
foreach (T item in list)
{
Add(item);
}
_suppressNotification = false;
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}
}
and in the gridControl
void s_MElementCollection_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
command.SetElementsOnGrid(ref this.grid);
}
internal void SetElementsOnGrid(ref Grid grid)
{
grid.Children.Clear();
SetHeaders(ref grid);
foreach (var item in s_Constructor.s_MElementCollection)
{
Grid.SetColumn(item, item.PositionDevice);
Grid.SetRow(item, item.PositionAntenna);
item.CommandParameter = item;
item.Command = UICommands.uiCommand;
if (item.IsEnabled)
if (item.IsError) item.Background = Brushes.OrangeRed; else item.Background = Brushes.Green;
else item.Background = Brushes.DarkRed;
grid.Children.Add(item);
}
}
Seems to work by now. What do you think about this aproach?
|
|
|
|