Click here to Skip to main content
15,890,882 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: No experience, learning C# & WPF Pin
Pete O'Hanlon2-Apr-10 10:02
mvePete O'Hanlon2-Apr-10 10:02 
GeneralRe: No experience, learning C# & WPF Pin
Jammer12-Apr-10 10:52
Jammer12-Apr-10 10:52 
GeneralRe: No experience, learning C# & WPF Pin
Jammer1-Apr-10 14:09
Jammer1-Apr-10 14:09 
GeneralRe: No experience, learning C# & WPF Pin
tim.gent@gmail.com2-Apr-10 0:22
tim.gent@gmail.com2-Apr-10 0:22 
GeneralRe: No experience, learning C# & WPF Pin
Jammer2-Apr-10 6:06
Jammer2-Apr-10 6:06 
QuestionMVVM Pin
DoctorMick30-Mar-10 4:30
DoctorMick30-Mar-10 4:30 
AnswerRe: MVVM Pin
Abhinav S30-Mar-10 4:42
Abhinav S30-Mar-10 4:42 
QuestionCustom user control binding Pin
Joe Rozario29-Mar-10 18:42
Joe Rozario29-Mar-10 18:42 
Dear friends

i have an issue .. i am new to WPF,

my requirement is to (binding "custom property" for user control)

can some one point out my mistake?

User Control
-------------
<Grid >
<TextBlock Name="textBlock1" Height="28" VerticalAlignment="Top" Background="AliceBlue"/>
</Grid>

UserControl Code behind
--------------------------


public partial class UserControl1 : UserControl
{

public UserControl1()
{
InitializeComponent();

}
public static readonly DependencyProperty coProperty = DependencyProperty.Register("CoType", typeof(int), typeof(UserControl1),
new UIPropertyMetadata(string.Empty, new PropertyChangedCallback(textChangedCallBack)));

int nType =0;
public int CoType
{
get {return nType;}
set {
nType =value;
textBlock1.Text = value.ToString();
}
}
static void textChangedCallBack(DependencyObject property,DependencyPropertyChangedEventArgs args)
{
UserControl1 searchTextBox = (UserControl1)property;
searchTextBox.CoType = (int)args.NewValue;
}

}
Main Form
-----------
<Grid>
<uc:UserControl1 CoType="{Binding CoTypeValue}"/>

</Grid>
Main Form Code behind is just InitializeComponent()

ViewModel
--------------

public int CoTypeValue
{
get { return nV; }
set {
if (value != nV)
{
nV = value;
OnPropertyChanged("CType");
}
}

}

The Error message i recive

Cannot create instance of 'UserControl1' defined in assembly 'WpfModelViewApplication2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation. Error at object 'System.Windows.Controls.Grid' in markup file

If i remove the Dependency property .. the error is not thrown .. but i want to binding for custom property.. and i not sure about the way i have implemented binding for custom property is the right way..


any help????
AnswerRe: Custom user control binding [modified] Pin
Parwej Ahamad30-Mar-10 3:46
professionalParwej Ahamad30-Mar-10 3:46 
GeneralRe: Custom user control binding Pin
Joe Rozario31-Mar-10 17:58
Joe Rozario31-Mar-10 17:58 
GeneralRe: Custom user control binding Pin
Parwej Ahamad31-Mar-10 18:16
professionalParwej Ahamad31-Mar-10 18:16 
GeneralRe: Custom user control binding Pin
Parwej Ahamad31-Mar-10 18:23
professionalParwej Ahamad31-Mar-10 18:23 
GeneralRe: Custom user control binding Pin
Parwej Ahamad31-Mar-10 18:55
professionalParwej Ahamad31-Mar-10 18:55 
GeneralRe: Custom user control binding Pin
Joe Rozario31-Mar-10 21:00
Joe Rozario31-Mar-10 21:00 
AnswerRe: Custom user control binding Pin
Super Lloyd31-Mar-10 18:09
Super Lloyd31-Mar-10 18:09 
QuestionStrange window is shown every time i save a silverlight project Pin
jonatan_55629-Mar-10 0:51
jonatan_55629-Mar-10 0:51 
AnswerRe: Strange window is shown every time i save a silverlight project Pin
Abhinav S29-Mar-10 7:12
Abhinav S29-Mar-10 7:12 
GeneralRe: Strange window is shown every time i save a silverlight project Pin
jonatan_55629-Mar-10 22:27
jonatan_55629-Mar-10 22:27 
GeneralRe: Strange window is shown every time i save a silverlight project Pin
Abhinav S30-Mar-10 3:52
Abhinav S30-Mar-10 3:52 
QuestionTo generate Text boxes, Combo boxes, IP Address controls at runtime Pin
luckyshah29-Mar-10 0:32
luckyshah29-Mar-10 0:32 
AnswerRe: To generate Text boxes, Combo boxes, IP Address controls at runtime [modified] Pin
Parwej Ahamad29-Mar-10 9:49
professionalParwej Ahamad29-Mar-10 9:49 
GeneralRe: To generate Text boxes, Combo boxes, IP Address controls at runtime Pin
luckyshah29-Mar-10 22:02
luckyshah29-Mar-10 22:02 
QuestionBinding Double click Pin
Joe Rozario28-Mar-10 23:18
Joe Rozario28-Mar-10 23:18 
AnswerRe: Binding Double click Pin
Pete O'Hanlon29-Mar-10 0:00
mvePete O'Hanlon29-Mar-10 0:00 
AnswerRe: Binding Double click Pin
Frank W. Wu12-Oct-10 9:23
Frank W. Wu12-Oct-10 9:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.