AlexSJC
发布于 2023-04-24 / 8 阅读
0
0

WPF 自定义属性

<Window x:Name="window" ...>
    <Grid>
        <TextBlock Text="{Binding Text, ElementName=window}" />
    </Grid>
</Window>
public static readonly DependencyProperty TextProperty =
    DependencyProperty.Register("Text", typeof(string), typeof(MainWindow));

public string Text
{
    get => (string)GetValue(TextProperty);
    set => SetValue(TextProperty, value);
}


评论