|
Where do I go in Visual Studio 2010 to create a new User Control that inherits an existing one that I created?
I want the new class to be usable in the IDE just as if I had chosen to create a new User Control that isn't based upon any other one.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
If you have:
public class MyControlBase : UserControl
{
}
you would just create another class:
public class MyControl : MyControlBase
{
}
If you are expecting something where you have UserControlA and then you add a UserControlB and you want UserControlB to be UserControlA + other stuff you would create a new UserControl (UserControlB) and then place an instance of UserControlA in it and do your thing.
|
|
|
|
|
I'm not aware of any features of VS2010 that support this.
You can just write the code for it.
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 can create a UserControl based on other control (Microsoft standard or your own). Like people already said, just make
public class AnotherControl : MyControl
or
public class AnotherControl : Button
If your base class was defined completely in code, everything is OK, and you can use Visual Studio designer:
<Test.MyControl x:Class="Test.MyAnotherControl">
or
<Button x:Class="Test.MyAnotherControl">
However, if your base class was defined in XAML like this
<UserControl x:Class="Test.MyControl">
then you cannot use Visual Studio designer anymore:
<Test.MyControl x:Class="Test.MyAnotherControl">
Error 'Test.MyControl' cannot be the root of a XAML file because it was defined using XAML. Line 1 Position 30
Makes sense?
|
|
|
|
|
Thanks for your response, Mike.
I eventually found out that you can't inherit XAML the way you can inherit code.
Your answer confirms just that.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
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
|
|
|
|