Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
swdev:dotnet:wpf:basic_controls [2013/01/22 14:25]
smayr [WebBrowser]
swdev:dotnet:wpf:basic_controls [2014/09/23 11:44] (current)
smayr [Expander]
Line 373: Line 373:
                       VerticalAlignment="Top" ExpandDirection="Down" Width="175">                       VerticalAlignment="Top" ExpandDirection="Down" Width="175">
                 <Grid Background="Cornsilk">                 <Grid Background="Cornsilk">
-                    <Grid.BitmapEffect+                    <Border Margin="5" BorderBrush="DarkGray" Background="White"  
-                        <DropShadowBitmapEffect /> +                            BorderThickness="1" CornerRadius="5"> 
-                    </Grid.BitmapEffect>+                        <Border.Effect> 
 +                            <DropShadowEffect BlurRadius="10" Opacity="0.5" /
 +                        </Border.Effect
 +                    </Border>
  
                     <Grid.RowDefinitions>                     <Grid.RowDefinitions>
Line 1291: Line 1294:
 </code> </code>
  
 +''TextBlock'' with truncated text showing tooltip displaying full text :
 +<code xml>
 +<TextBlock Width="100" TextTrimming="CharacterEllipsis" 
 +          ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Text}">
 +This is a long sentence with text.
 +</TextBlock>
 +</code>
 +Alternatively, use a behavior: [[http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2|Customizing "Lookful" WPF controls]]
 == TextBox == == TextBox ==
  
Line 1508: Line 1519:
 </code> </code>
  
-Execute a JavaScript routine from C#:+Execute a JavaScript routine from C#: (see more: [[http://www.dotnetfunda.com/articles/article840-working-with-webbrowser-in-wpf.aspx|Working with WebBrowser in WPF]])
 <code csharp> <code csharp>
-// Fields +public class TSampleApp 
-private WebBrowser aWebBrowser = new WebBrowser()+
-. . .+  // Fields 
 +  private WebBrowser aWebBrowser;   
 +  . . .
  
-// Constructor +  // Constructor 
-aWebBrowser.LoadCompleted -= new LoadCompletedEventHandler(aWebBrowser_LoadCompleted); +  public TSampleApp() 
-aWebBrowser.LoadCompleted += new LoadCompletedEventHandler(aWebBrowser_LoadCompleted);+  { 
 +    aWebBrowser = new WebBrowser(); 
 +    aWebBrowser.LoadCompleted -= new LoadCompletedEventHandler(aWebBrowser_LoadCompleted); 
 +    aWebBrowser.LoadCompleted += new LoadCompletedEventHandler(aWebBrowser_LoadCompleted); 
 +  } 
 +   
 +  public void LoadWebPage(string aWebPage) 
 +  { 
 +    // Load a webpage using Source property or Navigate() method 
 +     
 +    // Load an external website 
 +    aWebBrowser.Navigate("http://www.example.com"); 
 +    aWebBrowser.Navigate(new Uri("http://www.example.com", UriKind.RelativeOrAbsolute)); 
 + 
 +    // Load a local file 
 +    aWebBrowser.Navigate("Products/Catalog/prodspec.htm"); 
 +    aWebBrowser.Source = new Uri(@"pack://siteoforigin:,,,/Products/Catalog/prodspec.htm", UriKind.RelativeOrAbsolute); 
 +    
 +  }
                                  
-void aWebBrowser_LoadCompleted(object sender, NavigationEventArgs e) +  void aWebBrowser_LoadCompleted(object sender, NavigationEventArgs e) 
-+  
-  //aWebBrowser.InvokeScript("getAlert");  // call javascript function with no params +    // Call JavaScript routine after the document has been loaded completely 
-  //aWebBrowser.InvokeScript("LoadDoc", new object[] { "prod_Name.pdf" });  // call javascript function with params +    // Example: 
-  string AppDir = System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName); +    //aWebBrowser.InvokeScript("getAlert");  // call javascript function with no params 
-  string ProdSpecPDFFilePath = "file:///" + System.IO.Path.Combine(AppDir, string.Format(@"Products\Catalog\{0}.pdf", _SelectedProduct.Code)).Replace("\\", "\\\\");+    //aWebBrowser.InvokeScript("LoadDoc", new object[] { "prod_Name.pdf" });  // call javascript function with params 
 +    string AppDir = System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName); 
 +    string ProdSpecPDFFilePath = "file:///" + System.IO.Path.Combine(AppDir, string.Format(@"Products\Catalog\{0}.pdf", _SelectedProduct.Code)).Replace("\\", "\\\\");
             aWebBrowser.InvokeScript("LoadDoc", new object[] { ProdSpecPDFFilePath });             aWebBrowser.InvokeScript("LoadDoc", new object[] { ProdSpecPDFFilePath });
-        }+  } 
 +}   
 +</code> 
 + 
 +Sample HTML page with JavaScript to call: 
 +<code js> 
 +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
 +<html> 
 +<head> 
 +    <title>This page comes from Stream</title> 
 + 
 +    <script type="text/javascript"> 
 + function getAlert() 
 +
 +     alert("Hi the page is loaded!!!"); 
 +
 + window.onload = getAlert; 
 +  
 + function LoadDoc(message){ 
 +     document.write("Message : " + message); 
 +
 +    </script> 
 + 
 +</head> 
 +<body> 
 +    <input type="text" id="txtMessage" /> 
 +</body> 
 +</html>
 </code> </code>
 == Window == == Window ==