によってそれらを作成した後、私は私が
との国境のBackground
とBorderBrush
のためのデータバインディングを作成したい
WPFのC#のコードでボーダーとラベルを作成しましたここではラベル、プログラムコード
のBackground
は、私がその
void creatlbl()
{
Border b = new Border();
b.Name = "b11";
b.Margin = new Thickness(300,17,0,419);
b.Height = 32;
b.CornerRadius = new CornerRadius(5);
b.Width = 181;
b.BorderThickness = new Thickness(2);
b.HorizontalAlignment = HorizontalAlignment.Left;
lgingrd.Children.Add(b); //
Label l = new Label();
l.Name = "l111";
l.Content = "l111";
l.Height = 28;
l.Width = 177;
l.Foreground = (Brush)bc.ConvertFrom("#FF346D80");
l.FontSize = 20;
l.Background = (Brush)bc.ConvertFrom("#FF9AB426");
l.HorizontalContentAlignment = HorizontalAlignment.Center;
l.Padding = new Thickness(0,0,0,0);
l.Visibility = Visibility.Visible;
b.Child = l;
// here i want to set binding for border
// the background and borderbrush of border equal to the background of label
}
同じものです
<Border x:Name="brdbt" Margin="120,58,0,378"
BorderBrush="{Binding Background, ElementName=bt}" <!--this is the binding which i want-->
Height="32"
CornerRadius="5"
Width="181"
BorderThickness="2"
HorizontalAlignment="Left" Background="{Binding Background, ElementName=bt}">
<Button x:Name="bt" Content="btntxt" HorizontalAlignment="Left" VerticalAlignment="Top" Height="28" Width="177" Click="bt_click" BorderBrush="{x:Null}" Foreground="#FFE8EEF0" FontSize="20" Padding="1,-1,1,1" MouseEnter="bt_mcentr" MouseLeave="bt_mclv" Background="#FFE62828"/>
</Border>
上記のxaml型のバインドを境界線とラベルのC#コードで行う方法はありますか?