Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用IValueConverter调整绑定到数据源的图像大小_C#_Data Binding_Winrt Xaml_Ivalueconverter - Fatal编程技术网

C# 使用IValueConverter调整绑定到数据源的图像大小

C# 使用IValueConverter调整绑定到数据源的图像大小,c#,data-binding,winrt-xaml,ivalueconverter,C#,Data Binding,Winrt Xaml,Ivalueconverter,我有一个图像文件绑定到网格内的图像元素,如下所示 <FlipView x:Name="FlipView" ItemsSource="{Binding Source={StaticResource ItemsViewSource}}" SelectionChanged="FlipView_SelectionChanged"> <FlipView.ItemTemplate> <DataTemplate>

我有一个图像文件绑定到网格内的图像元素,如下所示

   <FlipView x:Name="FlipView" ItemsSource="{Binding Source={StaticResource ItemsViewSource}}" SelectionChanged="FlipView_SelectionChanged">
        <FlipView.ItemTemplate>
            <DataTemplate>
                <Grid SizeChanged="Grid_SizeChanged">
                    <Image Source="{Binding File, Converter={StaticResource ImageConverter}}" Stretch="None" />
                </Grid>
            </DataTemplate>
        </FlipView.ItemTemplate>
    </FlipView>
图像设置为“不拉伸”,因为我正在IValueConverter内部调整大小,以便小图像不会像素化,而大图像仍会缩小以适应屏幕

当我的应用程序大小更改时,如何触发IValueConverter重新计算当前显示的图像大小?

实现INotifyPropertyChanged界面,当应用程序大小更改时,设置文件属性值

public PropertyChangedEventHandler PropertyChanged;

private void NotifyPropertyChanged(string propertyName)
{
     PropertyChangedEventHandler handler = this.PropertyChanged;
     if (handler != null)
     {
          var e = new PropertyChangedEventArgs(propertyName);
          handler(this, e);
     }
}

private String file;

public String File
{
    get 
    { 
         return file; 
    }
    set
    {
         file = value;
         NotifyPropertyChanged("File");
    }
}

对不起,我不明白。我将使用什么来处理PropertyChangedEvent?它是数据绑定框架的一部分,将处理有效的属性。我还必须在与PropertyChanged的绑定上设置UpdateSource。是的,确实如此,您需要更新数据源。