SORU
20 NİSAN 2012, Cuma


WPF örnek Köprüyü kullanarak

Hyperlink kumanda ile WPF uygulama için köprü eklemenin birkaç öneri gördüm.

Benim kod kullanmaya çalışıyorum:

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        mc:Ignorable="d" 
        x:Class="BookmarkWizV2.InfoPanels.Windows.UrlProperties"
        Title="UrlProperties" Height="754" Width="576">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition></RowDefinition>
            <RowDefinition Height="40"/>
        </Grid.RowDefinitions>
        <Grid>
            <ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Auto" Grid.RowSpan="2">
                <StackPanel >
                    <DockPanel LastChildFill="True" Margin="0,5">
                        <TextBlock Text="Url:" Margin="5" 
                            DockPanel.Dock="Left" VerticalAlignment="Center"/>
                        <TextBox Width="Auto">
                            <Hyperlink NavigateUri="http://www.google.co.in">
                                    Click here
                            </Hyperlink>   
                        </TextBox>                      
                    </DockPanel >
                </StackPanel>
            </ScrollViewer>        
        </Grid>
        <StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Margin="0,7,2,7" Grid.Row="1" >
            <Button Margin="0,0,10,0">
                <TextBlock Text="Accept" Margin="15,3" />
            </Button>
            <Button Margin="0,0,10,0">
                <TextBlock Text="Cancel" Margin="15,3" />
            </Button>
        </StackPanel>
    </Grid>
</Window>

Aşağıdaki hatayı alıyorum:

''Türünün değerlerini desteklemiyor''. Köprü Metin özelliği

Neyi yanlış yapıyorum?

CEVAP
20 NİSAN 2012, Cuma


Eğer istediğiniz uygulama için açık bağlantı web browser Ekle HyperLink RequestNavigate etkinlik için bir işlevi bu program aracılığıyla açılır bir web tarayıcı ile adres olarak bir parametre.

<TextBlock>           
    <Hyperlink NavigateUri="http://www.google.com" RequestNavigate="Hyperlink_RequestNavigate">
        Click here
    </Hyperlink>
</TextBlock>

Kod-arkasında içinde buna benzer bir şey eklemek RequestNavigate olay işlemek gerekir.

private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
    Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
    e.Handled = true;
}

Buna ek olarak, ayrıca aşağıdaki ithalat gerekir.

using System.Diagnostics;
using System.Windows.Navigation;

Uygulamanızda böyle olmazdı.

oO

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • GoProTutorials

    GoProTutoria

    18 NİSAN 2011
  • The Fashion Sight

    The Fashion

    22 AĞUSTOS 2011
  • whiteboy7thst

    whiteboy7ths

    1 Temmuz 2009