Click here to Skip to main content
15,908,274 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Curios as to why this doesn't work... Pin
Michael Eber2-Jul-10 8:53
Michael Eber2-Jul-10 8:53 
GeneralRe: Curios as to why this doesn't work... Pin
Pete O'Hanlon2-Jul-10 21:31
mvePete O'Hanlon2-Jul-10 21:31 
GeneralRe: Curios as to why this doesn't work... Pin
Jammer5-Jul-10 23:38
Jammer5-Jul-10 23:38 
AnswerRe: Curios as to why this doesn't work... Pin
BechBej7-Jul-10 0:17
BechBej7-Jul-10 0:17 
QuestionCombobox.SelectedItem assignment not working when adding items statically Pin
xtr33me2-Jul-10 6:06
xtr33me2-Jul-10 6:06 
AnswerRe: Combobox.SelectedItem assignment not working when adding items statically Pin
Michael Eber2-Jul-10 7:12
Michael Eber2-Jul-10 7:12 
GeneralRe: Combobox.SelectedItem assignment not working when adding items statically Pin
xtr33me2-Jul-10 9:14
xtr33me2-Jul-10 9:14 
Questionselected item for WPF ListBox [modified] Pin
devvvy2-Jul-10 3:00
devvvy2-Jul-10 3:00 
hello

newbie to WPF, how do you set selected item for a list box?

<br />
SomeDataTab.Columns.Add("SomeData", typeof(string));<br />
SomeDataTab.Columns.Add("IsSelected", typeof(bool));<br />
<br />
Cmd = new SqlCommand(SQL, (SqlConnection)DevConn);<br />
...<br />
Rdr = Cmd.ExecuteReader();<br />
while (Rdr.Read())<br />
{<br />
	rw = SomeDataTab.NewRow();<br />
	SomeData = (string)Rdr["SomeData"];<br />
	if (SomeData == "TEMPLATE_OBJECTIVE")<br />
	{<br />
		SomeData = "SharedData";<br />
		rw["IsSelected"] = true;<br />
	}<br />
	else<br />
	{<br />
		rw["IsSelected"] = false;<br />
	}<br />
	rw["SomeData"] = SomeData;<br />
	SomeDataTab.Rows.Add(rw);<br />
}<br />
<br />
SomlstSomeData.DataContext = SomeDataTab.DefaultView;<br />


The above code shows how we bind to DataTable and following is xaml code:

<ListBox Name="lstSomeData" Grid.Row="0" Grid.Column="0">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay}" />
<Label Content="{Binding SomeData}"></Label>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>

I wish to know how to pre-select say an Item with value "AAA"?

Thanks!
dev
modified on Sunday, July 4, 2010 9:47 PM

AnswerRe: selected item for WPF ListBox Pin
BechBej5-Jul-10 9:24
BechBej5-Jul-10 9:24 
GeneralRe: selected item for WPF ListBox Pin
devvvy5-Jul-10 16:04
devvvy5-Jul-10 16:04 
GeneralRe: selected item for WPF ListBox Pin
BechBej7-Jul-10 0:25
BechBej7-Jul-10 0:25 
GeneralRe: selected item for WPF ListBox [modified] Pin
devvvy7-Jul-10 16:00
devvvy7-Jul-10 16:00 
QuestionWPF Layout Databinding Help Pin
_Maxxx_1-Jul-10 20:34
professional_Maxxx_1-Jul-10 20:34 
AnswerRe: WPF Layout Databinding Help Pin
Pete O'Hanlon1-Jul-10 21:47
mvePete O'Hanlon1-Jul-10 21:47 
GeneralRe: WPF Layout Databinding Help Pin
_Maxxx_2-Jul-10 0:56
professional_Maxxx_2-Jul-10 0:56 
GeneralRe: WPF Layout Databinding Help Pin
Pete O'Hanlon2-Jul-10 1:11
mvePete O'Hanlon2-Jul-10 1:11 
Questionhide a group name in a wpf data grid Pin
Salman Haider1-Jul-10 19:52
Salman Haider1-Jul-10 19:52 
QuestionHow to make forward the MenuControl 's MenuBar list name its getting hide in my solution at run time Pin
Ch.Gayatri Subudhi1-Jul-10 18:55
Ch.Gayatri Subudhi1-Jul-10 18:55 
AnswerRe: How to make forward the MenuControl 's MenuBar list name its getting hide in my solution at run time Pin
Abhinav S1-Jul-10 20:10
Abhinav S1-Jul-10 20:10 
Questionget control name in a canvas Pin
ctlqt121-Jul-10 18:38
ctlqt121-Jul-10 18:38 
AnswerRe: get control name in a canvas Pin
Abhinav S1-Jul-10 20:02
Abhinav S1-Jul-10 20:02 
GeneralRe: get control name in a canvas Pin
ctlqt123-Jul-10 17:07
ctlqt123-Jul-10 17:07 
QuestionBinding to an objects member variable in a List Pin
xtr33me1-Jul-10 12:01
xtr33me1-Jul-10 12:01 
AnswerRe: Binding to an objects member variable in a List Pin
Venkatesh Mookkan1-Jul-10 17:44
Venkatesh Mookkan1-Jul-10 17:44 
GeneralRe: Binding to an objects member variable in a List Pin
xtr33me2-Jul-10 1:12
xtr33me2-Jul-10 1:12 

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.