WPF Binding-2019-04-15

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_30807313/article/details/89315999

            this.lsitboxdemo.ItemsSource = demolsit;
            this.lsitboxdemo.DisplayMemberPath = "Name";
            Binding binding = new Binding("SelectedItem.Flag") { Source=this.lsitboxdemo};
            this.txtbox.SetBinding(TextBox.TextProperty,binding);

 <local:InflateConverter x:Key="ic"></local:InflateConverter>
    </Window.Resources>nment="Left" Margin="10,189,0,37" VerticalAlignment="Stretch"  Width="290"/>

 <ContentControl Content="{Binding ElementName=lsitboxdemo, Path=SelectedItem.Flag,Converter={StaticResource ic }}" Name="Change_Page1"  HorizontalAlig    <Window.Resources>

    public class InflateConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null)
            {
                Type t = Type.GetType(value.ToString());
                return Activator.CreateInstance(t);
            }
            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

猜你喜欢

转载自blog.csdn.net/qq_30807313/article/details/89315999
WPF