R
Rolf Welskes
Hello,
because there are no managed news group for window presentation foundation
and one
has told me I can use this, here my problem:
I have the following simple test:
<Window x:Class="Test02.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 Background="LightGray" Name="grid01">
<TextBlock Text="{Binding Path=Str01}" Background="Beige" Height="21"
Margin="36,32,122,0" Name="textBlock1" VerticalAlignment="Top" />
<TextBlock Text="{Binding Path=Str02}" Background="Beige" Height="21"
Margin="36,64,122,0" Name="textBlock2" VerticalAlignment="Top" />
</Grid>
</Window>
public partial class Window1 : Window
{
class ClsA
{
string str01;
string str02;
public ClsA(string str01, string str02) { this.str01 = str01;
this.str02 = str02; }
public string Str01
{
get { return str01; }
set { str01 = value; }
}
public string Str02
{
get { return str02; }
set { str02 = value; }
}
}
ClsA clsA = new ClsA("this ist string one", "this is string two");
public Window1()
{
InitializeComponent();
grid01.DataContext = clsA;
}
}
In this sample I set
grid01.DataContext = clsA in code.
I dont want this I want to set it in Xaml:
<Grid Background="LightGray" Name="grid01"
DataContext="---??????------">
So I can see the datacontext I use in xaml.
Further, I do NOT want to lay the ClsA means variable clsA in resources -
because ClsA , means clsA
can be very complex and need be generated by code.
So is there a solution, a syntactical possibility to write
<Grid Background="LightGray" Name="grid01"
DataContext="---??????------">
where ????? is in code not in xaml ?
Thank you for any help.
Best Regards
Rolf Welskes
because there are no managed news group for window presentation foundation
and one
has told me I can use this, here my problem:
I have the following simple test:
<Window x:Class="Test02.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 Background="LightGray" Name="grid01">
<TextBlock Text="{Binding Path=Str01}" Background="Beige" Height="21"
Margin="36,32,122,0" Name="textBlock1" VerticalAlignment="Top" />
<TextBlock Text="{Binding Path=Str02}" Background="Beige" Height="21"
Margin="36,64,122,0" Name="textBlock2" VerticalAlignment="Top" />
</Grid>
</Window>
public partial class Window1 : Window
{
class ClsA
{
string str01;
string str02;
public ClsA(string str01, string str02) { this.str01 = str01;
this.str02 = str02; }
public string Str01
{
get { return str01; }
set { str01 = value; }
}
public string Str02
{
get { return str02; }
set { str02 = value; }
}
}
ClsA clsA = new ClsA("this ist string one", "this is string two");
public Window1()
{
InitializeComponent();
grid01.DataContext = clsA;
}
}
In this sample I set
grid01.DataContext = clsA in code.
I dont want this I want to set it in Xaml:
<Grid Background="LightGray" Name="grid01"
DataContext="---??????------">
So I can see the datacontext I use in xaml.
Further, I do NOT want to lay the ClsA means variable clsA in resources -
because ClsA , means clsA
can be very complex and need be generated by code.
So is there a solution, a syntactical possibility to write
<Grid Background="LightGray" Name="grid01"
DataContext="---??????------">
where ????? is in code not in xaml ?
Thank you for any help.
Best Regards
Rolf Welskes