Click here to Skip to main content
15,887,485 members
Home / Discussions / WPF
   

WPF

 
QuestionMicrosoft Expression Blend 4 Pin
εїзεїзεїз14-Jun-11 21:47
εїзεїзεїз14-Jun-11 21:47 
AnswerRe: Microsoft Expression Blend 4 Pin
Richard MacCutchan14-Jun-11 22:13
mveRichard MacCutchan14-Jun-11 22:13 
AnswerRe: Microsoft Expression Blend 4 Pin
Abhinav S16-Jun-11 21:39
Abhinav S16-Jun-11 21:39 
Questiongnn?? "To view this content, please install: Microsoft Silverlight" Pin
Super Lloyd14-Jun-11 20:36
Super Lloyd14-Jun-11 20:36 
QuestionWeird scrollbar behaviour in DataGrid when manipulating single Row Visibility Pin
Durango6613-Jun-11 23:54
Durango6613-Jun-11 23:54 
AnswerRe: Weird scrollbar behaviour in DataGrid when manipulating single Row Visibility Pin
Mycroft Holmes14-Jun-11 1:14
professionalMycroft Holmes14-Jun-11 1:14 
GeneralRe: Weird scrollbar behaviour in DataGrid when manipulating single Row Visibility Pin
Durango6614-Jun-11 1:34
Durango6614-Jun-11 1:34 
QuestionButton in DataGridTemplateColumn throws ArgumentOutOfRangeException Pin
humble.apprentice13-Jun-11 10:13
humble.apprentice13-Jun-11 10:13 
Hi all,
I added to an already working (perhaps that was my mistake) a DataGridTemplateColumn containing a Button. The code looks like this:

<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:local='clr-namespace:MyAssembly;assembly=MyAssembly>
    <Button x:Name='btnShowSubgrid' Tag='{Binding ID}' Click='btnShowSubgrid_Click' Margin='4' Width='20'>
      <Button.Content>
        <Image x:Name='imgButtonTemplate' Source='Images/rightBlueArrow.png' />
      </Button.Content>
    </Button>
</DataTemplate>


All columns are runtime generated, and again, if I don't add this column, it all works fine.

This button's tag is bound to a column called "ID". There is another column that binds to "ID" but I don't think that's an issue. Even went as far as to remove all "embellisher" tags and content only leaving it with x:Name only but no luck.

This is how I add the column:

DataGridTemplateColumn buttonColumn = new DataGridTemplateColumn(); 
 
                    using (StreamReader reader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("MyAssembly.CellTemplates.ButtonCellTemplate.xml"))) 
                    { 
                        String str = reader.ReadToEnd(); 
                        str = str.Replace("(ColumnToBind)", _gridDefinition.SubGrid.Param); 
 
                        buttonColumn.CellTemplate = (DataTemplate)XamlReader.Load(str); 
                    } 
 
                    dgGrid.Columns.Add(buttonColumn);


The ArgumentOutOfRangeException is thrown after the MainPage_Loaded event and it says:

Microsoft JScript runtime error: Unhandled Error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
at System.Windows.PresentationFrameworkCollection`1.InsertDependencyObject(Int32 index, DependencyObject value)
at System.Windows.Controls.UIElementCollection.InsertInternal(Int32 index, UIElement value)
at System.Windows.PresentationFrameworkCollection`1.Insert(Int32 index, T value)
at System.Windows.Controls.DataGrid.InsertDisplayedColumnHeader(DataGridColumn dataGridColumn)
at System.Windows.Controls.DataGrid.OnApplyTemplate()
at System.Windows.FrameworkElement.OnApplyTemplate(IntPtr nativeTarget)

My DataGrid has AutoGenerateColumns set to "false". Has somebody have the same issue? How have you fixed it?

BTW, I'm using Silverlight 4.

All help is appreciated!
Thanks,

humble.apprentice

QuestionHow to properly size ElementHost Pin
xusword13-Jun-11 8:28
xusword13-Jun-11 8:28 
QuestionProperty in ViewModel not displayed in View [modified] Pin
kurmanc13-Jun-11 5:07
kurmanc13-Jun-11 5:07 
AnswerRe: Property in ViewModel not displayed in View Pin
kurmanc14-Jun-11 2:08
kurmanc14-Jun-11 2:08 
QuestionReferencing resources in an external assembly Pin
RugbyLeague13-Jun-11 4:07
RugbyLeague13-Jun-11 4:07 
AnswerRe: Referencing resources in an external assembly Pin
SledgeHammer0113-Jun-11 10:01
SledgeHammer0113-Jun-11 10:01 
GeneralRe: Referencing resources in an external assembly Pin
RugbyLeague13-Jun-11 21:21
RugbyLeague13-Jun-11 21:21 
QuestionThe property or field has not been initialized. Pin
bhavnvyas13-Jun-11 1:21
bhavnvyas13-Jun-11 1:21 
QuestionStyle for Current Page of Datapager. Pin
www.Developerof.NET10-Jun-11 1:40
www.Developerof.NET10-Jun-11 1:40 
AnswerRe: Style for Current Page of Datapager. Pin
Mark Salsbery10-Jun-11 6:46
Mark Salsbery10-Jun-11 6:46 
GeneralRe: Style for Current Page of Datapager. Pin
www.Developerof.NET10-Jun-11 18:01
www.Developerof.NET10-Jun-11 18:01 
QuestionMoving Data from Silverlight to ASp.net via SQl server Pin
Vimalsoft(Pty) Ltd9-Jun-11 9:20
professionalVimalsoft(Pty) Ltd9-Jun-11 9:20 
AnswerRe: Moving Data from Silverlight to ASp.net via SQl server Pin
Mark Salsbery9-Jun-11 10:33
Mark Salsbery9-Jun-11 10:33 
GeneralRe: Moving Data from Silverlight to ASp.net via SQl server Pin
Vimalsoft(Pty) Ltd9-Jun-11 19:06
professionalVimalsoft(Pty) Ltd9-Jun-11 19:06 
GeneralRe: Moving Data from Silverlight to ASp.net via SQl server Pin
Mark Salsbery9-Jun-11 19:10
Mark Salsbery9-Jun-11 19:10 
GeneralRe: Moving Data from Silverlight to ASp.net via SQl server Pin
Vimalsoft(Pty) Ltd9-Jun-11 19:14
professionalVimalsoft(Pty) Ltd9-Jun-11 19:14 
GeneralRe: Moving Data from Silverlight to ASp.net via SQl server Pin
Mark Salsbery10-Jun-11 6:10
Mark Salsbery10-Jun-11 6:10 
AnswerRe: Moving Data from Silverlight to ASp.net via SQl server Pin
Mycroft Holmes9-Jun-11 14:15
professionalMycroft Holmes9-Jun-11 14:15 

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.