Hirdetés

Új hozzászólás Aktív témák

  • peacetoy

    csendes tag

    Sziasztok!

    Kellene egy kis segítség WPF-en belül is DOM-hoz.

    A problémám az ( az egyik ) pl. hogy egy webBrowser control által betöltött oldal szélességét és magasságát szeretném egy változóba eltárolni.

    Amire eddig jutottam:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using mshtml;

    namespace WpfApplication4
    {
    public partial class MainWindow : Window
    {
    public HTMLDocument dom = new HTMLDocument();

    public MainWindow()
    {
    InitializeComponent();

    webBrowser1.Source = new Uri("http://www.valamilyen_oldal.hu/");
    }

    private void webBrowser1_Loaded(object sender, RoutedEventArgs e)
    {
    dom = (HTMLDocument)webBrowser1.Document;
    MessageBox.Show(dom.documentElement.offsetWidth.ToString());
    }
    }
    }

    Erre a kódra NullReferenceException hibával elszáll... Ha segítenétek megköszönném...

Új hozzászólás Aktív témák