Hello,
I've already created a topic in this forum, and I need your help once again.
I work with the same configuration (it's the same application) : Telerik + MS Prism
Link : Close tabs - RadTabControl + Prism
I have a problem with the Binding and RadTabControl.
I have a button to add a RadTabItem in my RadTabControl, and the content of the RadTabItem work with a ContentTemplate.
The content is a form with some TextBox and each textbox has a Binding with an Object in my Model.
CODE :
So, here the XAML code of my RadTabControl :
(I deleted some field for a short version)
I have a simple RadButton with this event :
The constructor in my XAML.cs is :
In my Model I have two attribute :
My Model implement INotifyPropertyChanged - (And sorry for french name...)
The AddAddress() Method (in the model) :
I not include the system to change the address when we select an other Tab.
PROBLEM :
The first time we add an address (add a Tab in the TabControl), the binding doesn't work. I need to add two address for work. I don't find why ! The binding work only if I click the Button (to add an other address) if there is already a Tab in the TabControl.
ATTACHED FILE :
You can download a demo here : Download
If you need more informations, please tell me.
Thank you in advance for your answer.
Regards,
G.B.
[EDIT] : Nobody shall have the beginning of solution ? I don't find how to fix this problem !
I've already created a topic in this forum, and I need your help once again.
I work with the same configuration (it's the same application) : Telerik + MS Prism
Link : Close tabs - RadTabControl + Prism
I have a problem with the Binding and RadTabControl.
I have a button to add a RadTabItem in my RadTabControl, and the content of the RadTabItem work with a ContentTemplate.
The content is a form with some TextBox and each textbox has a Binding with an Object in my Model.
CODE :
So, here the XAML code of my RadTabControl :
<telerik:RadTabControl Name="RadTabControlAddress" SelectionChanged="RadTabControlAddress_SelectionChanged"> |
<telerik:RadTabControl.ItemContainerStyle> |
<Style TargetType="{x:Type telerik:RadTabItem}"> |
<Setter Property="ContentTemplate"> |
<Setter.Value> |
<DataTemplate> |
<Grid Name="Grid"> |
<Grid.ColumnDefinitions> |
<ColumnDefinition Width="100" /> |
<ColumnDefinition Width="*"/> |
</Grid.ColumnDefinitions> |
<Grid.RowDefinitions> |
<RowDefinition /> |
</Grid.RowDefinitions> |
<TextBlock Text="{Loc address1}" Grid.Row="0" Grid.Column="0"></TextBlock> |
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Adresse.Adresse1 }" Height="30" Margin="5"></TextBox> |
</Grid> |
</DataTemplate> |
</Setter.Value> |
</Setter> |
</Style> |
</telerik:RadTabControl.ItemContainerStyle> |
</telerik:RadTabControl> |
I have a simple RadButton with this event :
private void AddAddressTab() |
{ |
_model.AddAddress(); |
RadTabItem itemToAdd = new RadTabItem() |
{ |
Header = "New Tab" |
}; |
RadTabControlAddress.Items.Add(itemToAdd); |
RadTabControlAddress.SelectedIndex = RadTabControlAddress.Items.Count - 1; |
} |
The constructor in my XAML.cs is :
public AjouterView(AjouterViewModel model) |
{ |
InitializeComponent(); |
// Sauvegarde du model dans un attribut de la classe. |
_model = model; |
// On se sert de notre model en tant que DataContext. |
this.DataContext = model; |
//AddAddressTab(); |
} |
In my Model I have two attribute :
private IAdresse _adresse = null; |
public IAdresse Adresse |
{ |
get { return _adresse; } |
set |
{ |
_adresse = value; |
OnPropertyChanged("Adresse"); |
} |
} |
The AddAddress() Method (in the model) :
public void AddAddress() |
{ |
IAdresse address = new Adresse("Just a test"); |
ListAdresse.Add(address); |
Adresse = address; |
} |
I not include the system to change the address when we select an other Tab.
PROBLEM :
The first time we add an address (add a Tab in the TabControl), the binding doesn't work. I need to add two address for work. I don't find why ! The binding work only if I click the Button (to add an other address) if there is already a Tab in the TabControl.
ATTACHED FILE :
You can download a demo here : Download
If you need more informations, please tell me.
Thank you in advance for your answer.
Regards,
G.B.
[EDIT] : Nobody shall have the beginning of solution ? I don't find how to fix this problem !