Click here to Skip to main content
16,008,299 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Another MVVM questionn regarding updating info on other controls? Pin
Christian Amado21-Jul-12 11:45
professionalChristian Amado21-Jul-12 11:45 
GeneralRe: Another MVVM questionn regarding updating info on other controls? Pin
Alisaunder21-Jul-12 12:30
Alisaunder21-Jul-12 12:30 
GeneralRe: Another MVVM questionn regarding updating info on other controls? Pin
Mycroft Holmes21-Jul-12 13:52
professionalMycroft Holmes21-Jul-12 13:52 
GeneralRe: Another MVVM questionn regarding updating info on other controls? Pin
Alisaunder21-Jul-12 14:59
Alisaunder21-Jul-12 14:59 
GeneralRe: Another MVVM questionn regarding updating info on other controls? Pin
Mycroft Holmes21-Jul-12 16:14
professionalMycroft Holmes21-Jul-12 16:14 
GeneralRe: Another MVVM questionn regarding updating info on other controls? Pin
Pete O'Hanlon22-Jul-12 21:52
mvePete O'Hanlon22-Jul-12 21:52 
QuestionAdding datagrid cell images at runtime doesn't appear in cell Pin
alleyes20-Jul-12 8:40
professionalalleyes20-Jul-12 8:40 
GeneralRe: Adding datagrid cell images at runtime doesn't appear in cell Pin
Christian Amado21-Jul-12 12:03
professionalChristian Amado21-Jul-12 12:03 
Try this (works on Silverlight too):
Create a converter class:
C#
public sealed class ImageConverter : IValueConverter
{
    public object Convert(object value, Type targetType,
                          object parameter, CultureInfo culture)
    {
        try
        {
            return new BitmapImage(new Uri((string)value));
        }
        catch 
        {
            return new BitmapImage();
        }
    }

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

In your XAML you must add a new resource and implement a convert in your image element inside the CellTemplate. Remember to add the extension namespace on your xaml file header.
XML
<DataGrid
    Name="dgDevices"
    AutoGenerateColumns="False"
    CanUserAddRows="False"
    ItemsSource="{Binding Scanners}" SelectionChanged="dgDevices_SelectionChanged">            <DataGrid.Resources>
      <extension:ImageConverter x:key="imgConverter" />
    </DataGrid.Resources>    
    <DataGrid.Columns>
        <DataGridTemplateColumn Header="Device Image">
            <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <Image Name="imgScanner" Source="{Binding Path=ImageFile,
        Converter={StaticResource imgConverter}}" }" Height="100" />
                </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
        </DataGridTemplateColumn>
        <DataGridTemplateColumn Header="Details" Width="*">
            <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <TextBlock TextWrapping="Wrap">
                        <TextBlock Text="{Binding Path=FriendlyName}"/>
                        <Hyperlink NavigateUri="{Binding Path=URL}" RequestNavigate="Hyperlink_RequestNavigate">
                            <TextBlock Text="{Binding Path=URL}"/>
                        </Hyperlink>
                    </TextBlock>
                </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
        </DataGridTemplateColumn>
    </DataGrid.Columns>
</DataGrid>

Hope its helps Big Grin | :-D
Christian Amado
MCITP | MCTS | MOS | MTA
DCE 0★ 1★ 2★ 3★ 4★ 5★
Bronze level MVA
Olimpia ☆ ★★★

GeneralRe: Adding datagrid cell images at runtime doesn't appear in cell Pin
alleyes22-Jul-12 17:07
professionalalleyes22-Jul-12 17:07 
GeneralUnintended Save Issue WPF Pin
eddieangel20-Jul-12 7:20
eddieangel20-Jul-12 7:20 
GeneralRe: Unintended Save Issue WPF Pin
Ian Shlasko20-Jul-12 7:31
Ian Shlasko20-Jul-12 7:31 
GeneralRe: Unintended Save Issue WPF Pin
eddieangel20-Jul-12 7:37
eddieangel20-Jul-12 7:37 
GeneralRe: Unintended Save Issue WPF Pin
Ian Shlasko20-Jul-12 7:45
Ian Shlasko20-Jul-12 7:45 
GeneralRe: Unintended Save Issue WPF Pin
eddieangel20-Jul-12 7:49
eddieangel20-Jul-12 7:49 
GeneralRe: Unintended Save Issue WPF Pin
Ian Shlasko20-Jul-12 8:16
Ian Shlasko20-Jul-12 8:16 
QuestionButton Style Question Pin
Kevin Marois19-Jul-12 9:21
professionalKevin Marois19-Jul-12 9:21 
AnswerRe: Button Style Question Pin
Wayne Gaylard19-Jul-12 20:15
professionalWayne Gaylard19-Jul-12 20:15 
Questiontip for scrollviewer Pin
caradri18-Jul-12 23:10
caradri18-Jul-12 23:10 
GeneralRe: tip for scrollviewer Pin
Wayne Gaylard18-Jul-12 23:38
professionalWayne Gaylard18-Jul-12 23:38 
GeneralRe: tip for scrollviewer Pin
caradri19-Jul-12 1:16
caradri19-Jul-12 1:16 
GeneralRe: tip for scrollviewer Pin
Mycroft Holmes19-Jul-12 12:48
professionalMycroft Holmes19-Jul-12 12:48 
GeneralRe: tip for scrollviewer Pin
Christian Amado19-Jul-12 17:43
professionalChristian Amado19-Jul-12 17:43 
GeneralRe: tip for scrollviewer Pin
Pete O'Hanlon19-Jul-12 20:20
mvePete O'Hanlon19-Jul-12 20:20 
GeneralRe: tip for scrollviewer Pin
Mycroft Holmes19-Jul-12 23:19
professionalMycroft Holmes19-Jul-12 23:19 
GeneralRe: tip for scrollviewer Pin
Pete O'Hanlon19-Jul-12 23:27
mvePete O'Hanlon19-Jul-12 23:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.