|
How about you add a "Parent" property of type "State" that refers to the state the County is in? That way, States can have collections of Counties, and you are only modifying one collection still.
As far as binding to those Counties, perhaps you could create a wrapper class. It would internally store a collection of states and would expose each County in all those States. You could then bind to that wrapper class instance. You may want to do some work to make it observable as well.
Or instead of that wrapper, you could nest list views.
|
|
|
|
|
There are really two things you need to do here...
1) Build a list of Counties
2) Be able to, from a County, reference the "parent" State
Fortunately, both of these are easy to do:
For #1, a little LINQ makes this a snap.
Counties = States.SelectMany(state => state.Counties);
As for #2, you'll have to make some minor changes to your County object. I would suggest adding the State as a parameter in the constructor:
public County(State parent)
{
this.State = parent;
}
public State State { get; private set; }
That way, you can just bind to State.StateName.
|
|
|
|
|
i tried to print using the SL Printing API.
I'm wondering when does the Size of the PrintableArea change(usually it's 1122x793)??? and depending on what it change ???
thanks
"For as long as men massacre animals, they will kill each other. Indeed, he who sows the seed of murder and pain cannot reap joy and love." Pythagoras
modified on Wednesday, May 4, 2011 10:22 AM
|
|
|
|
|
The PageVisual refers to the UIElement that is being rendered out, so if you set it to point to the root element it refers to the size of the root element as measured for the print page. Following this, you can deduce that the size changes size based on the element it's printing out (for instance, if you set the PageVisual to an element that only fills half the width of the root element).
|
|
|
|
|
Thanks for the answer Pete and sorry for mistake as my query was regarding PrintableArea(not PageVisual).
"For as long as men massacre animals, they will kill each other. Indeed, he who sows the seed of murder and pain cannot reap joy and love." Pythagoras
|
|
|
|
|
Hi,
I have completed a WPF application in c#.
Now, I would like to start using the MVVM design pattern in this application.
At present, One of the windows forms i.e. frmPayment is populated as follows:
private void Window_Loaded(object sender, RoutedEventArgs e)
{
DataTable _dtPayments = GetPayments(_intID);
DataView defaultView = _dtPayments.DefaultView;
dgPayments.ItemsSource = defaultView;
}
////////////////////////////////////////////////////////
Now, to get started with the MVVM, I have created a class called clsPaymentViewModel
with the following code:
public class clsPaymentViewModel : INotifyPropertyChanged
{
clsPaymentManager _PaymentManager = new clsPaymentManager();
public clsPaymentViewModel(int intID)
{
DataCollection = _PaymentManager.GetPayments(intID);
}
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
private ObservableCollection<clsPayment> mDataCollection;
public ObservableCollection<clsPayment> DataCollection
{
get { return mDataCollection; }
set
{
mDataCollection = value;
RaisePropertyChanged("DataCollection");
}
}
}
{
public ObservableCollection<clsPayment> GetPayments(int intID)
{
ObservableCollection<clsPayment> ret;
List<clsPayment> payments = GetPaymentsCol(intID);
ret = new ObservableCollection<clsPayment>(payments);
return ret;
}
}
public class clsPaymentManager
frmPayment has this code in it:
clsPaymentViewModel _ViewModel;
public frmPayment()
{
InitializeComponent();
int _intID = 1
_ViewModel = new clsPaymentViewModel(_intID);
}
//////////////////////
QUESTION:
Based on the above code, what should the DataContext be for dgPayment in frmPayment?
I was thinking of putting something like:
DataContext="{Binding Source={StaticResource clsPaymentViewModel}}"
But this is not right because there should be a _intID
What do you think please?
Thanks
|
|
|
|
|
At the top of the window definition define it like so:
<Window x:Class="MyWindow"
...etc...
xmlns:vm="clr-namespace:Namespace.VM.Is.In"
>
<Window.DataContext>
<vm:ViewModelClassName x:Name="viewModel" />
</Window.DataContext>
...etc...
</Window>
|
|
|
|
|
This is what I have in brief:
But not sure if _intID needs to be specified anywhere.
What do you think please?
<Window x:Class="frmPayment"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:DataAccess;assembly=DataAccess"
Title="Payment" Height="336" Width="741"
...
<Window.Resources>
<!--<local:clsPaymentViewModel x:Key="clsPaymentViewModel" />
<Grid Width="804" Height="370">
<!--DataContext="{Binding Source={StaticResource clsPaymentViewModel}}"-->
<DataGrid AutoGenerateColumns="False" Height="124" Margin="5,169,86,0" Name="dgPayments" ;
<!--ItemsSource="{Binding Path=DataCollection}">-->
|
|
|
|
|
Hi,
I have a scenario wherein i need to migrate an existing Windows application of mine to an web application using silverlight. I am unable to add references of my existing C#2.0 dll's to the Silverlight projects due to CLR incompatibility.
Is there any way by which i can reuse my existing Entities,BusinessAccess layer and DataAccess Layer and only change the UI part?
|
|
|
|
|
Silverlight does not use the same version of the CLR as standard .NET applications. This means that you cannot use existing DLLs directly.
Let me explain in a bit more detail. When you run a .NET application (any .NET application), the CLR has a system called Fusion which works with the embedded assembly manifest (inside the DLL/exe). The manifest contains a load of information, such as embedded resources, type system details, and details of the required assemblies for this process (hint: this info is really useful for Reflection). Fusion won't find the desktop CLR references because the .NET BCL libraries aren't there as far as it's concerned (remember that it is aimed at targetting machines which may not have the full runtime installed).
If you want to add your existing code, the common trick is to create a bunch of new Silverlight class libraries and then add the class files into these libraries using the "Add as link" option in the add existing item (you add as a link so that if fix your existing application, your Silverlight application will get the fix simply by recompiling it). There are a couple of caveats though - as the class libraries are different, certain features may not be present so you may have to find workrounds (e.g. you can't add a reference to log4net). Silverlight also runs at a more secured level, so you can't do things like P/Invoke in the browser.
|
|
|
|
|
hi
Silvelright printing APIs aren't enough to custom printing.
Crystal Report is not supported in Silverlight (there isn't an Official version for Silverlight).
There is any other good solution for printing in silverlight ??? How did you print in your Silverlight Application ???
Thanks
"For as long as men massacre animals, they will kill each other. Indeed, he who sows the seed of murder and pain cannot reap joy and love." Pythagoras
|
|
|
|
|
jadughar wrote: Silvelright printing APIs aren't enough to custom printing.
Says who? They are very flexible - it's this flexibility that makes it hard to use it. If you don't want to cope with that flexibility, then you should take a look at using SQL Server Reporting Services with Report Sharp Shooter[^] from Perpetuum Software.
|
|
|
|
|
I use SSRS and output to a new ASPX form for the report viewer. I looked at report sharpshooter but the demo would not install so it never really got past that point. It did seem a mite expensive for a viewer host.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi Mycroft
Do you have an example that show how using ssrs with silverlight ???
thanks
"For as long as men massacre animals, they will kill each other. Indeed, he who sows the seed of murder and pain cannot reap joy and love." Pythagoras
|
|
|
|
|
jadughar wrote:
Silvelright printing APIs aren't enough to custom printing.
Export to excel (and then print) could be an option.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
Hi Abhinav
Thanks foir the answer. Bu thow do you do to "save as Excel" ??
I don't print only usual report which contain records(grid's rows) loaded from database but also custom page with some fields compiled by user and some field copiled with data looaded from db.
Thanks
"For as long as men massacre animals, they will kill each other. Indeed, he who sows the seed of murder and pain cannot reap joy and love." Pythagoras
|
|
|
|
|
|
is it possible to "export as PDF" ??
"For as long as men massacre animals, they will kill each other. Indeed, he who sows the seed of murder and pain cannot reap joy and love." Pythagoras
|
|
|
|
|
I think that would be even worse that the export to excel idea.
I was surprised and impressed that Perpentium followed up on my above comment, they obviously keep an watch on this forum and are interested in helping.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: think that would be even worse that the export to excel idea.
It was supposed to be a workaround (an ugly one perhaps)!
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
Everything is a workaround when it comes to Silverlight printing. I just happen to think Excel and PDF are probably the worst options of a particular bad lot. I'm reasonably happy with the SSRS and ASPX solution I have but it is still a kludge.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: Everything is a workaround when it comes to Silverlight printing.
I so totally agree.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
I created a RIA aplication (SL4) that populates a grid from an MSSQL 2008 DB.
App has been working fine.
My question is: If I make some changes to the table design (add new column or change the name of the column), what is the best way to refresh that connection without having to start from scratch (craete the app, create the ADO, create the domain services...)
any help is greatly appreciated
|
|
|
|
|
In your Entity model (edmx), there should be a context menu option "Update from database" - that shoud pick up your changes.
C# has already designed away most of the tedium of C++.
|
|
|
|
|
hi,
I have a problème, in my application (world cup, south affrica) I have a 64 Matchs
in Groupe Phase i have a 48 Matchs and in Final Phase i have a 16 Matchs
Question:
How i do for affiche this Matchs and what's tools wpf used ?
help me please.
|
|
|
|