当用户从对话框中选择图像时,更新网格行单元格图像

时间:2014-12-18 21:09:32

标签: c# wpf

我在DevExpress网格中并排显示一个图像和一个按钮,当用户点击按钮时,我希望用户能够从FileDialog中选择一个应立即显示在图像字段中的新图像。当用户更新行中的其余字段时,IPropertyChange事件应触发并存储该行。我怎样才能在WPF中实现这一目标?

XAML:

<dxg:GridColumn FieldName="Image" Header="Image" >
     <dxg:GridColumn.CellTemplate>
          <DataTemplate>
               <DockPanel>
                    <Image Source="{Binding RowData.Row.Image, Converter={StaticResource BinaryImageConverter}}" Width="100" />
                    <Button x:Name="BrowseFilePath" Height="20" Width="20" Content="..." Visibility="Hidden" CommandParameter="{Binding RowData.Row}" />
                    <!--<Button x:Name="BrowseFilePath" Height="20" Width="20" Content="..." Visibility="Hidden" Command="{Binding Source={x:Static local:FacilitiesBrowseImagePathDialog.BrowsePathCommand}}" CommandParameter="{Binding RowData.Row}"  />-->
               </DockPanel>
               <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=dxg:GridRow}}" Value="True">
                         <Setter TargetName="BrowseFilePath" Property="Visibility" Value="Visible" />
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>
       </dxg:GridColumn.CellTemplate>
 </dxg:GridColumn>

0 个答案:

没有答案