如何以System.Windows.Controls.Image的字符串形式获取路径

时间:2015-07-31 11:49:15

标签: c# wpf image bitmap path

我希望将路径作为WPF图像的字符串,并将其作为Bitmap的参数。我需要字符串中的路径。 我有可变图像的WPF图像 我有

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete && self.routineToEdit.stretches.count > 2) {
        // this needs to be added to keep an consistency error from being thrown
        // you'll also need to end updates when it's done deleting
        [self.tableView beginUpdates];
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
        // pbasdf suggested this for handling the NSOrderedSet
        NSMutableOrderedSet *tempSet = self.myNSManagedObject.myNSOrderedSet.mutableCopy;
        [tempSet removeObjectAtIndex:indexPath.row];
        self.myNSManagedObject.myNSOrderedSet = tempSet;
        [self.tableView endUpdates];
        // and you need to save the context so the deletion persists
        [self saveContext];

    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }
}

2 个答案:

答案 0 :(得分:0)

在XAML中显式创建一个BitmapImage:

var bitmapImage = (BitmapImage)image.Source;
var uriSource = bitmapImage.UriSource;

现在,您可以使用以下代码访问BitmapImage的Source属性:

select s.col1,
       coalesce(max(col2) over (partition by col1), -1) as col2
from source s;

答案 1 :(得分:0)

只需致电ToString

image.Source.ToString();

请注意,这不会与任何 ImageSource后代一起使用,但在这种情况下,当您为图像源设置URI时,它将起作用。