Click here to Skip to main content
15,907,183 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: dialogs must be user-initiated silverlight 4 Pin
NTheOne18-Apr-11 18:53
NTheOne18-Apr-11 18:53 
AnswerRe: dialogs must be user-initiated silverlight 4 Pin
Abhinav S22-Apr-11 8:30
Abhinav S22-Apr-11 8:30 
QuestionImage control not getting resized while resizing window Pin
DavJes18-Apr-11 0:33
DavJes18-Apr-11 0:33 
AnswerRe: Image control not getting resized while resizing window Pin
DavJes18-Apr-11 0:34
DavJes18-Apr-11 0:34 
QuestionHow to check duplicate data in listbox.itemtemplate Pin
Rocky2317-Apr-11 23:44
Rocky2317-Apr-11 23:44 
AnswerRe: How to check duplicate data in listbox.itemtemplate Pin
Abhinav S18-Apr-11 5:03
Abhinav S18-Apr-11 5:03 
GeneralRe: How to check duplicate data in listbox.itemtemplate Pin
Rocky2318-Apr-11 23:03
Rocky2318-Apr-11 23:03 
QuestionBind a UserControl string array property to containing window Pin
Jean-Louis Leroy17-Apr-11 23:08
Jean-Louis Leroy17-Apr-11 23:08 
Hello,

I have a UserControl that exposes a Selection property:

public partial class FeatureSelectionControl : UserControl
{

  public string[] Selection
  {
    get { return (string[])GetValue(SelectionProperty); }
    set { SetValue(SelectionProperty, value); }
  }

  public static readonly DependencyProperty SelectionProperty =
      DependencyProperty.Register("Selection", typeof(string[]), typeof(FeatureSelectionControl), new UIPropertyMetadata(new string[] { }));

I want to use it in a window and bind the control's property to one of the window's properties:
<Window Name="Window" ...>
    <local:FeatureSelectionControl Selection="{Binding ElementName=Window,Path=CustomerGroups}" ...>
    </local:FeatureSelectionControl>

Code behind:
public partial class WindowCounterpartyGroupRiskReview : Window
{
  public WindowCounterpartyGroupRiskReview()
  {
    CustomerGroups = new string[] { };
    InitializeComponent();
  }

  public string[] CustomerGroups { get; set; }

This crashes with a "first chance exception of type 'System.NullReferenceException' occurred in PresentationFramework.dll Additional information: Object reference not set to an instance of an object". STack trace is:
	PresentationFramework.dll!System.Windows.Markup.BamlRecordReader.ProvideValueFromMarkupExtension(System.Windows.Markup.MarkupExtension markupExtension = null, object obj = {System.Windows.Markup.BamlCollectionHolder}, object member = null) + 0x52 bytes	
 	PresentationFramework.dll!System.Windows.Markup.BamlRecordReader.ReadPropertyArrayEndRecord() + 0x5f bytes	
 	PresentationFramework.dll!System.Windows.Markup.BamlRecordReader.ReadRecord(System.Windows.Markup.BamlRecord bamlRecord) + 0x636 bytes	
 	PresentationFramework.dll!System.Windows.Markup.BamlRecordReader.Read(bool singleRecord = false) + 0x1c bytes	
 	PresentationFramework.dll!System.Windows.Markup.TreeBuilderBamlTranslator.ParseFragment() + 0xc9 bytes	
 	PresentationFramework.dll!System.Windows.Markup.TreeBuilder.Parse() + 0xf bytes	
 	PresentationFramework.dll!System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream stream, System.Windows.Markup.ParserContext parserContext, object parent, bool closeStream) + 0xc7 bytes	
 	PresentationFramework.dll!System.Windows.Application.LoadComponent(object component, System.Uri resourceLocator) + 0x16e bytes	
>	CRRT.exe!CRRT.WindowCounterpartyGroupRiskReview.InitializeComponent() Line 1 + 0xb bytes	C#


However, when I change my code and make the property a mere string, I don't get an exception and everything works as expected.

Any idea ?
AnswerRe: Bind a UserControl string array property to containing window Pin
Jean-Louis Leroy17-Apr-11 23:41
Jean-Louis Leroy17-Apr-11 23:41 
QuestionReceiveAsync Issues Pin
veggieCoder15-Apr-11 8:13
veggieCoder15-Apr-11 8:13 
AnswerRe: ReceiveAsync Issues Pin
SledgeHammer0115-Apr-11 10:05
SledgeHammer0115-Apr-11 10:05 
QuestionPRISM in Silverlight Pin
NTheOne15-Apr-11 0:30
NTheOne15-Apr-11 0:30 
AnswerRe: PRISM in Silverlight Pin
Tarun.K.S15-Apr-11 0:59
Tarun.K.S15-Apr-11 0:59 
AnswerRe: PRISM in Silverlight Pin
Pete O'Hanlon15-Apr-11 1:59
mvePete O'Hanlon15-Apr-11 1:59 
AnswerRe: PRISM in Silverlight Pin
Abhinav S15-Apr-11 17:58
Abhinav S15-Apr-11 17:58 
QuestionWPF PopUp control Pin
Rahul Chitte14-Apr-11 1:59
Rahul Chitte14-Apr-11 1:59 
AnswerRe: WPF PopUp control Pin
Pete O'Hanlon14-Apr-11 2:20
mvePete O'Hanlon14-Apr-11 2:20 
AnswerRe: WPF PopUp control Pin
Ian Shlasko14-Apr-11 3:19
Ian Shlasko14-Apr-11 3:19 
AnswerRe: WPF PopUp control Pin
Abhinav S14-Apr-11 3:32
Abhinav S14-Apr-11 3:32 
GeneralRe: WPF PopUp control Pin
Tarun.K.S14-Apr-11 3:50
Tarun.K.S14-Apr-11 3:50 
GeneralRe: WPF PopUp control Pin
Abhinav S14-Apr-11 4:05
Abhinav S14-Apr-11 4:05 
QuestionAnother Dummies question (sorry) Pin
Johnny J.14-Apr-11 0:53
professionalJohnny J.14-Apr-11 0:53 
AnswerRe: Another Dummies question (sorry) Pin
Pete O'Hanlon14-Apr-11 1:33
mvePete O'Hanlon14-Apr-11 1:33 
GeneralRe: Another Dummies question (sorry) Pin
Johnny J.14-Apr-11 2:26
professionalJohnny J.14-Apr-11 2:26 
GeneralRe: Another Dummies question (sorry) Pin
Pete O'Hanlon14-Apr-11 2:52
mvePete O'Hanlon14-Apr-11 2:52 

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.