2
I have an application where the user can select the company to be worked on. When he selects, I would like this information to go to the Application Title... This is possible?
The attribute Title is in the parent window. Already this event Mousedoubleclick is in a Usercontrol son... This is my doubt, how to pass from the son to the Father..
For now I have this Textblock to add the information in the title:
<TextBlock Text="{Binding Titulo, RelativeSource={RelativeSource FindAncestor,AncestorType=Window}}" HorizontalAlignment="Center" VerticalAlignment="Top"/>
Title:
private string _titulo;
public string Titulo
{
get
{
return _titulo;
}
set
{
_titulo = value;
}
}
What can I do here when the user selects?
private void dataGridEmpresa_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
--- AQUI! ---
}
After the change:
<my:EscolherEmpresa TitleValue="{Binding Title,RelativeSource={RelativeSource FindAncestor,AncestorType=Window}, Mode=OneWayToSource}"/>
Where I open Usercontrol:
private void main_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.F5){
tbTitulo.Text = "ESCOLHER EMPRESA PARA TRABALHAR";
MainMdiContainer.Children.Clear();
MainMdiContainer.Children.Add(new MdiChild()
{
Margin = new Thickness(-10, -28, 0, 0),
Width = this.Width - 20,
Height = this.Height - 113,
//WindowState = System.Windows.WindowState.Maximized,
Style = null,
Content = new Telas.EscolherEmpresa()
});
}
}
Where exactly is your difficulty? It is in how to build the Binding in the shaman, in the implementation of the interface Inotifypropertychanged in the class that has the property Title or is on how to extract, from Grid, the field title in the method
dataGridEmpresa_MouseDoubleClick()
?– ramaral
I’m not using MVVM @ramaral, I just wanted to take some information from my Datagrid to the application title..
– Emerson
Okay, but the information is still too little. You talk about a Textblock, either that information is placed in it or in the attribute Title of Window. If it is in the attribute it is enough, after having this information, to do in the method
dataGridEmpresa_MouseDoubleClick()
this.Title = varialvelQueTem_a_Infromacao;
– ramaral
So, but the attribute Title is in the father window. Already this event Mousedoubleclick is in a Usercontrol son... This is my doubt, how to pass from the son to the Father...
– Emerson
In question you do not say that.
– ramaral
Sorry @ramaral, I changed the question.
– Emerson