Skip to main content

Microsoft Silverlight

Answered Question Silverlight datagrid questionsRSS Feed

(0)

cloudeleven
cloudeleven

Member

Member

0 points

4 Posts

Silverlight datagrid questions

I have 2 questions about the silverlight datagrid:

 - How can I programmatically set a multiple selection of the datagrid? I have an array of selected rowID's and want to iterate the rows and set the ones that are in my array to 'selected'. Couldn't find anything that does this.

 - Is it possible to use indexers to set the binding of a DataGridColumn? For example:

DataGridTextColumn textColumn = new DataGridTextColumn();

Binding binding = new Binding("MyArray[x]");

This doesn't work, but how can I accomplish this?

Skyrunner
Skyrunner

Contributor

Contributor

2489 points

485 Posts

Silverlight MVP

Re: Silverlight datagrid questions

I think you cannot do that.

But you can do that:

textColumn.DataContext = MyArray[x];
Binding binding = new Binding();

 

HarshBardhan
HarshBar...

Star

Star

9908 points

1,719 Posts

Re: Silverlight datagrid questions

Hi,

You Can set Selection mode by  Specifying Selection mode Property.

Which is taking two value Single or Extended.

Example is below..

x:Name="myDataGrid" Style="{StaticResource grid}"

AutoGenerateColumns="False" HeadersVisibility="Column" SelectionMode="Single" >

 

Mark as answer if this post answered your question.

Harsh Bardhan

cloudeleven
cloudeleven

Member

Member

0 points

4 Posts

Re: Silverlight datagrid questions

Hi Harsh,

 Yes I know about the selectionmode property, I already have that set on "Extended". But my question is how I can set the selected (highlighted) rows programmatically.

cloudeleven
cloudeleven

Member

Member

0 points

4 Posts

Re: Silverlight datagrid questions

Hi Skyrunner,

 My DataGridTextColumn doesn't seem to have a DataContext property. Are you using beta2?

Skyrunner
Skyrunner

Contributor

Contributor

2489 points

485 Posts

Silverlight MVP

Re: Silverlight datagrid questions

cloudeleven:

Hi Skyrunner,

 My DataGridTextColumn doesn't seem to have a DataContext property. Are you using beta2?

 

In fact I didn't try.

Try with GridView control.

gridView1.DataContext = xxx;

cloudeleven
cloudeleven

Member

Member

0 points

4 Posts

Re: Silverlight datagrid questions

Gridview? are we both on the silverlight forum?

Skyrunner
Skyrunner

Contributor

Contributor

2489 points

485 Posts

Silverlight MVP
Answered Question

Re: Silverlight datagrid questions

Sorry DataGrid1.DataContext = xxx;

I'm tired.

codism
codism

Member

Member

372 points

121 Posts

Re: Silverlight datagrid questions

Any one has the answer/workaround to the original question in this thread? I am working on an UI that allows user to adjust the sequence of a list. To allow user to continuously press "Move Up" button, I have to preserve the user's selection between two clicks.

Thanks 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities