|
Hi i have a problem when i'm trying to bind a selected item from a grid to the page, it works fine the 1st time but if i select another item from DataGrid the data bound to the textbox remains with the 1st value
here is my Code:
thx
xmal:
=====
<UserControl xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" x:Class="SilverlightApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns ="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<StackPanel>
<sdk:DataGrid x:Name="Grid1" AutoGenerateColumns="False" >
<sdk:DataGrid.Columns>
<sdk:DataGridTemplateColumn Header="Job Post ID">
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Job_Posting_ID}"></TextBlock>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
<sdk:DataGridTemplateColumn Header="Job Title">
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding job_title}"></TextBlock>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
<sdk:DataGridTemplateColumn Header="Details">
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button x:Name="btnDetails" Content="Show Details" Click="btnDetails_Click"></Button>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
</sdk:DataGrid.Columns>
</sdk:DataGrid>
<TextBox Margin="10,50,10,10" x:Name="txt_JobTitle" Width="200"></TextBox>
</StackPanel>
</Grid>
</UserControl>
XAML.cs
=======
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ServiceModel.DomainServices.Client;
namespace SilverlightApplication1
{
public partial class MainPage : UserControl
{
Web.Services.DomainService1 DomainObj;
public MainPage()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(Page_Loaded);
}
void Page_Loaded(object sender, RoutedEventArgs e)
{
DomainObj = new Web.Services.DomainService1();
Grid1.ItemsSource = DomainObj.Load(DomainObj.GetJob_PostingQuery()).Entities;
}
private void btnDetails_Click(object sender, RoutedEventArgs e)
{
decimal ID = decimal.Parse(((Web.Model.Job_Posting)((Button)sender).DataContext).Job_Posting_ID.ToString());
DomainObj.Load(DomainObj.GetJP_JobDetailsQuery(ID), Completed, null);
}
void Completed(LoadOperation lo)
{
foreach(Web.Model.DataStructure itm in lo.Entities)
{
txt_JobTitle.Text = itm.Job_Title;
}
}
}
}
RIA Domain Service Class:
==========================
namespace SilverlightApplication1.Web.Services
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Linq;
using System.ServiceModel.DomainServices.EntityFramework;
using System.ServiceModel.DomainServices.Hosting;
using System.ServiceModel.DomainServices.Server;
using SilverlightApplication1.Web.Model;
[EnableClientAccess()]
public class DomainService1 : LinqToEntitiesDomainService<ItoRecDBEntities>;
{
public IQueryable<Web.Model.DataStructure> GetJP_JobDetails(decimal JobDetail_ID)
{
var Qry = (from jp in ObjectContext.Job_Posting
where jp.Job_Posting_ID == JobDetail_ID
select new DataStructure
{
Job_Title = jp.job_title,
});
return Qry;
}
}
}
My View Class : (in web project)
==================================
using System;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel.DomainServices.EntityFramework;
using System.ServiceModel.DomainServices.Hosting;
using System.ServiceModel.DomainServices.Server;
namespace SilverlightApplication1.Web.Model
{
[DataContract()]
public class DataStructure : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(PropertyChangedEventArgs e)
{
if (PropertyChanged != null)
PropertyChanged(this, e);
}
decimal _job_Posting_ID;
[Key]
[DataMember()]
[Editable(true)]
public decimal job_Posting_ID
{
get
{
return _job_Posting_ID;
}
set
{
_job_Posting_ID = value;
OnPropertyChanged(new PropertyChangedEventArgs("job_Posting_ID"));
}
}
string _Job_Title;
[DataMember()]
[Editable(true)]
public string Job_Title
{
get
{
return _Job_Title;
}
set
{
if (value == string.Empty)
{
throw new ArgumentException("sadas dasd asda d as");
}
else
{
_Job_Title = value;
}
OnPropertyChanged(new PropertyChangedEventArgs("Job_Title"));
}
}
}
}
-- Modified Thursday, December 23, 2010 5:18 AM
|
|
|
|
|
In my wcf project, I can see several operationcontracts
I do not see the new one I have just added i.e.
inside the interface class:
...
...
...
[OperationContract]
void WriteAllSQL(string strXML);
in the .svc.cs file
...
...
...
public void WriteAllSQL(string strXML)
{
...
...
}
On the client, when I create an instance to the wcf, I only see the previous operationcontracts and not the new ones.
Have i not done something correctly?
|
|
|
|
|
Check whether you refreshed your service reference on the client side.
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.
My latest tip/trick
|
|
|
|
|
yes, I have already and still do not see the new method inside the wcf.
As an extra test, I used the wcf client test and give it the endpoint. It shows the new method but still can not figure out why after refreshing the service references, the client does not see the new method.
Note that I see the old methods I created but anything new I add, does not get shown to the client in th esilverlight project.
Thanks
|
|
|
|
|
Well I would suggest just delete all your service references, client config file, bin and obj folder and then add them again.
HTH.
modified on Monday, December 27, 2010 4:58 AM
|
|
|
|
|
whenever i start my silverlight application this exception raises
any solution...
|
|
|
|
|
Is the Silverlight runtime installed on your machine?
The browser should install it automatically.
Check this[^] out as well.
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.
My latest tip/trick
|
|
|
|
|
Hello all,
I am learning WPF now. I have a window which will launch a popup on click of a button. The popup contains a user control. I need to pass some parameters like first name,last name to the user control. I am from an asp.net background so my thought is like to pass these parameters as query string and assign it to the text box in popup. Any way, it is not possible in windows and I am sure there are better methods.
I am thinking about declaring a public get-set property in the popup for each parameters(I don't think I need dependency property). Then I will assign the values from the window.
Is it a good way of doing it?
Thanks in advance,
afsal
modified on Wednesday, December 22, 2010 10:15 AM
|
|
|
|
|
If your pop-up's job is to display first name and last name then I would guess that you probably have (for example) a Customer object, with properties of FirstName and LastName (for example)
your usercontrol could bind to such an object
your popup then would need an instance of that object to set as the datasource - so either have a public property
public Customer CurrentCustomer
{
set
{
}
}
or have a constructor which takes a Customer as a parameter, and performs the binding.
Using the property at least gives you the potential option of changing the Customer without closing and re-opening the pop up.
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
Please. Buy some books. We can't handhold you through the entire process of deployment. There comes a time when you have to read up on this yourself. The last two pages read like one long homage to your woes deploying this application with you creating a new thread everytime you come up against something.
|
|
|
|
|
Lolz... No kidding. Arkiboys posts questions about every 10 minutes.
|
|
|
|
|
hello I'm looking for a Flowchart control in WPF, I don't think there's an Open Source alternative in this regards (Also checked Visfire), and seems like prominent/best seller which come up first in Google is Mind Fusion
I missed anything? And better suggestion?
dev
|
|
|
|
|
Any of the replies here[^] helped?
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.
My latest tip/trick
|
|
|
|
|
You posted this only a few hours earlier. You have been a member long enough to know that behaviour like this is unacceptable in the forums. Now, pack it in.
|
|
|
|
|
I am developing a 4.0 WPF application. It works great under Windows 7, but it behaves strangely under XP:
In XP, when the app opens new windows, these windows are devoid of content in their client areas until I move them with the mouse. As soon as I manually activate the window with the mouse, then the client area gets painted. However this quirk does not show itself in Windows 7.
Could this be a bug in the XP implementation of WPF?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Not in XP itself. In your video drivers.
Remember, WPF handles all the drawing for you via software and hardware acceleration. Make sure you have the latest and correct video drivers installed. Also, in your Advanced Display Settings (can't give you the exact way to get to those because I am on Win7), but its in the Display Settings somewhere. I think there is an advanced button on one of the pages. Anyways, its that page with the big slider control on it that lets you slide to the left to disable levels of driver acceleration. This often fixes rendering issues like these, but also makes things slower.
Theres not much you can do about it other then update your video drivers and/or get a new video card with less buggy video drivers.
Not having buggy video drivers is *CRITICAL* with WPF.
|
|
|
|
|
Wow, thanks Mr. Sledgehammer. I hadn't thought of that. I'll see about updating the drivers and making adjustments.
I have to demo the app for the boss, and I don't want it doing that during the demo!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
On the windows server 2003, I am trying to deploy a silverlight 4 / .net 4 application.
I get the error page not found when trying to browse to the page.
Are there any settings or installs I need to do on the windows server 2003 machine?
Thanks
|
|
|
|
|
We already know. Stop reposting.
|
|
|
|
|
This is now solved as I had to set the web service extensions to allowed for asp.net 4
Thank you
|
|
|
|
|
I'm missing something in my understanding of how to use DP validation and probably in custom control design in general.
Here's the problem:
I've created a numeric text box, yeah another one. One feature it supports is a flag for whole number vs real number support. Another feature is Increment, where an Increment is 1 for whole numbers and 0 to 1 for real numbers.
I have implemented Validation Callbacks as:
var propertyMetadata = new FrameworkPropertyMetadata(1.0, OnIncrementChanged, OnCoerceIncrementProperty);
IncrementProperty = DependencyProperty.Register("Increment",
typeof (Double),
typeof (NumericTextBox),
propertyMetadata,
IsIncrementValid);
public static readonly DependencyProperty IncrementProperty;
[EditorBrowsable]
public Double Increment
{
get { return (Double) GetValue(IncrementProperty); }
set { SetValue(IncrementProperty, value); }
}
private static object OnCoerceIncrementProperty(DependencyObject sender, object data)
{
var value = (Double) data;
var numericTextBox = (NumericTextBox) sender;
if (numericTextBox.IsWholeNumberOnly)
{
return 1.0;
}
if (value > 0 && value <= 1)
{
return value;
}
return 1.0;
}
private static void OnIncrementChanged(DependencyObject obj, DependencyPropertyChangedEventArgs eventArgs){}
private static bool IsIncrementValid(object value)
{
var val = (Double) value;
return val > 0 && val <= 1;
}
My logic actually works fine, the problem is that it does not play nice with wpf. For example, in the properties window, if I set the flag for whole number and I enter .5 for the Increment the property window updates as expected, back to one (silently, without an indication I entered a bogus value). However, the XAML still shows the .5. Aside from that the logic of the control works correctly, it ignores the .5. If I type in the XAML editor I get no warning that the value is bogus. I believe this behavior is due to the logic in the coerce callback.
If I set a value in the properties window or in XAML that fails the logic of the IsIncrementValid callback, such as 2, I get a warning from both the properties window and the XAML editor and the value is never set.
Apparently the coerce validation callback is working for the properties window but not the XAML. The IsIncrementValid callback is working in the XAML and in the properties window. Of course the IsIncrementValid callback applies to the type not an instance. So the behavior I need is for IsIncrementValid to apply to instances so I can base the evaluation of validity on another instance property. In fact what I need is to be able to apply the code in the coerce callback to the isValid callback.
Any suggestions that would shed light on how to do this correctly would be appreciated.
I would also appreciate any suggestions for eliminating the plumbing code for DP's. Other then the callbacks, DP's are very much boilerplate.
Thanks in advance.
modified on Wednesday, December 22, 2010 7:30 AM
|
|
|
|
|
Hi,
I need to add custom deserialization to my Silverlight 4 application, but I'm having a VERY hard time, any help will be appreciated (please send codes ). I have tried to implement IClientMessageFormatter at nausea, but no luck...
I've also noticed a search on CP for IClientMessageFormatter gives no results, which makes me think I'm on a wrong track...
Can anyone please point me at a nice sample SL (4) app that does this, or a good article that shows the implementation (e.g. the MSDN article tells you all about IClientMessageFormatter except give you a nice example on how/where to implement it your app, and I don't mean implement it in your class )
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|
|
Hii..
Could anyone plz let me know how to create Flow chart elements dynamically using SilverLight..
Thanks
Pari
|
|
|
|
|
All you neeed to do is create a shape object, either in XAML or in code, and then use that shape wherever applicable. Here's a link that discusses shapes and drawing:
http://msdn.microsoft.com/en-us/library/cc189073(v=vs.95).aspx[^]
.45 ACP - because shooting twice is just silly ----- "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." - J. Jystad, 2001
|
|
|
|
|
this is the structure I have:
The development is done on my machine as follows:
using VS2010, silverlight 4
1- Silverlight application is created as a project
2- silverlight app has service references to the wcf project
3- web project is a simple project which has the clientbin folder and a default.aspx page
When running the .sln on my machine, all works fine.
I have copied the entire folders for both my wcf and web projects from my local machine into the c:\inetpub\wwwroot of the webserver (Windows server 2003).
on the web server, created two virtual directories. One for the web and one for the wcf project. each points to the appropriate folder under c:\inetpub\wwwroot
I made sure the endpoints in the file Servicereferences.ClientConfig under the wcf project in the webserver is pointing to the webservername:80
The webserver does have the correct mime file type i.e. .xap
I have also added the domain policy files onto webserver machine's C:/inetpub/wwwwroot/
In IIS, under the web project virtual directory, when I right click, browse, then it says "Page can not be found"
What have I done wrong please?
Thanks
|
|
|
|