コード例 #1
0
        public EditWindow(MultiMedia media)
        {
            InitializeComponent();
            combo_type.ItemsSource = Enum.GetValues(typeof(MultiMedia.MediaType));

            var titleBind = new Binding("Title") { Source = media, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged };
            field_Title.SetBinding(TextBox.TextProperty, titleBind);
            var artistBind = new Binding("Artist") { Source = media, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged };
            field_Artist.SetBinding(TextBox.TextProperty, artistBind);
            var albumBind = new Binding("Album") { Source = media, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged };
            field_Album.SetBinding(TextBox.TextProperty, albumBind);
            var genreBind = new Binding("Genre") { Source = media, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged };
            field_Genre.SetBinding(TextBox.TextProperty, genreBind);

            var mediaBind = new Binding("Media")
            {
                Source = media,
                Mode = BindingMode.TwoWay,
                Converter = new UriConverter(),
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };
            field_media_uri.SetBinding(TextBox.TextProperty, mediaBind);

            var coverBind = new Binding("Cover_Uri")
                                    {
                                        Source = media, Mode = BindingMode.TwoWay, Converter = new UriConverter(), UpdateSourceTrigger=UpdateSourceTrigger.PropertyChanged
                                    };
            field_Cover_uri.SetBinding(TextBox.TextProperty, coverBind);

            var typeBind = new Binding("Type") { Source = media, Mode = BindingMode.TwoWay };
            combo_type.SetBinding(Selector.SelectedItemProperty, typeBind);
        }
コード例 #2
0
 private void CompletedMediaForm(object sender, RoutedEventArgs e)
 {
     var media = new MultiMedia
     {
         Artist = this.field_Artist.Text,
         Title = this.field_Title.Text,
         Album = this.field_Album.Text,
         Genre = this.field_Genre.Text,
         Media = (this.field_media_uri.Text == string.Empty) ? null : new Uri(this.field_media_uri.Text),
         Cover_Uri = (this.field_Cover_uri.Text == string.Empty) ? null : new Uri(this.field_Cover_uri.Text),
         Type = (MultiMedia.MediaType)this.combo_type.SelectedItem
     };
     this.collection.Add(media);
     DialogResult = true;
 }