Click here to Skip to main content
15,900,378 members
Home / Discussions / WPF
   

WPF

 
GeneralWrong forum Pin
Pete O'Hanlon1-Oct-08 23:13
mvePete O'Hanlon1-Oct-08 23:13 
AnswerRe: Ajax Tool Error Pin
Paul Conrad3-Oct-08 11:17
professionalPaul Conrad3-Oct-08 11:17 
QuestionWindowsFormsHost and keyboard focus Pin
Paul A. Howes1-Oct-08 4:15
Paul A. Howes1-Oct-08 4:15 
GeneralRe: WindowsFormsHost and keyboard focus Pin
Paul A. Howes1-Oct-08 4:32
Paul A. Howes1-Oct-08 4:32 
AnswerRe: WindowsFormsHost and keyboard focus Pin
Patrick Klug8-Oct-08 17:35
Patrick Klug8-Oct-08 17:35 
QuestionControl similar to new message control Pin
_iobuf30-Sep-08 7:03
_iobuf30-Sep-08 7:03 
AnswerRe: Control similar to new message control Pin
Paul Conrad6-Oct-08 18:52
professionalPaul Conrad6-Oct-08 18:52 
QuestionWPF Data binding Pin
koleraba27-Sep-08 8:21
koleraba27-Sep-08 8:21 
I would like to bind the SelectedIndex property of ComboBox to a property that is defined in my class that extends the Window class. It is hard to explain what exactly I want, so I will try to explain it with a simple example:

here is my .xaml code:

<Window x:Class="WpfApplication3.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ComboBox Grid.Row="0" x:Name="cmbSource" SelectionChanged="cmbSource_SelectionChanged">
<ComboBox.Items>
<ComboBoxItem> 1 </ComboBoxItem>
<ComboBoxItem> 2 </ComboBoxItem>
</ComboBox.Items>
</ComboBox>
<ComboBox Grid.Row="1" x:Name="cmbDestination" SelectedIndex="{Binding ElementName=Item, Path=Index}"> <!-- this doesn't work -->
<ComboBox.Items>
<ComboBoxItem>Item 1</ComboBoxItem>
<ComboBoxItem>Item 2</ComboBoxItem>
</ComboBox.Items>
</ComboBox>
</Grid>
</Window>

and here is my code-behind code:

namespace WpfApplication3
{
public partial class Window1 : Window
{
private Test _item;
public Test Item
{
get{return this._item;}
set{this._item = value;}
}

public Window1()
{
InitializeComponent();
}

private void cmbSource_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Item = new Test(cmbSource.SelectedIndex);
}
}

public class Test
{
private int _index;

public int Index
{
get { return this._index; }
set { this._index = value; }
}

public Test(int index)
{
Index = index;
}
}
}

When I was tring to solve this problem, I extended my Window1 class so it implements INotifyPropertyChanged interface, than I extended the Test class the same way, but nothing works. I even tried to define the Item Property as a DependencyProperty, but that didn't work either. Any idea will be appreciated.

thanks
Uros
AnswerRe: WPF Data binding Pin
User 27100928-Sep-08 6:12
User 27100928-Sep-08 6:12 
GeneralRe: WPF Data binding Pin
koleraba29-Sep-08 6:01
koleraba29-Sep-08 6:01 
QuestionSimple Textbox validation Pin
Aslesh26-Sep-08 5:27
Aslesh26-Sep-08 5:27 
AnswerRe: Simple Textbox validation Pin
Pete O'Hanlon26-Sep-08 8:18
mvePete O'Hanlon26-Sep-08 8:18 
GeneralRe: Simple Textbox validation Pin
Aslesh26-Sep-08 9:57
Aslesh26-Sep-08 9:57 
GeneralRe: Simple Textbox validation Pin
Pete O'Hanlon26-Sep-08 10:14
mvePete O'Hanlon26-Sep-08 10:14 
GeneralRe: Simple Textbox validation Pin
Aslesh26-Sep-08 10:25
Aslesh26-Sep-08 10:25 
GeneralRe: Simple Textbox validation Pin
Pete O'Hanlon26-Sep-08 10:40
mvePete O'Hanlon26-Sep-08 10:40 
GeneralRe: Simple Textbox validation Pin
Aslesh26-Sep-08 11:18
Aslesh26-Sep-08 11:18 
GeneralRe: Simple Textbox validation Pin
Pete O'Hanlon26-Sep-08 23:28
mvePete O'Hanlon26-Sep-08 23:28 
AnswerRe: Simple Textbox validation Pin
Wes Aday26-Sep-08 9:26
professionalWes Aday26-Sep-08 9:26 
QuestionHow to handle TabControl's Tab Index changing in WPF ? Pin
Mohammad Dayyan25-Sep-08 13:39
Mohammad Dayyan25-Sep-08 13:39 
AnswerRe: How to handle TabControl's Tab Index changing in WPF ? Pin
User 27100925-Sep-08 15:15
User 27100925-Sep-08 15:15 
GeneralSelected Tab index? Pin
Mohammad Dayyan25-Sep-08 15:27
Mohammad Dayyan25-Sep-08 15:27 
GeneralRe: Selected Tab index? Pin
User 27100925-Sep-08 15:30
User 27100925-Sep-08 15:30 
GeneralRe: Selected Tab index? Pin
Mohammad Dayyan25-Sep-08 15:43
Mohammad Dayyan25-Sep-08 15:43 
GeneralRe: Selected Tab index? Pin
User 27100925-Sep-08 15:44
User 27100925-Sep-08 15:44 

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.