Posts

Showing posts with the label Xaml

Aligning Content In A WPF Viewbox

Answer : Try VerticalAlignment="Top" and HorizontalAlignment="Left" on your viewbox. It will cause it to be anchored to the top and left side. <Grid> <Viewbox VerticalAlignment="Top" HorizontalAlignment="Left"> ... </Viewbox> </Grid> If you want it to completely fill (but keep it uniform) you can use Stretch="UniformToFill"

Add A PDF Viewer To A WPF Application

Answer : As already suggested by @NawedNabiZada, one tried and straightforward way is to use embedded InternetExplorer to show Adobe PDF Reader ActiveX control. So it assumes you are running on Windows and have Adobe PDF Reader installed. Then you create a user control, window etc. that contains following control: <WebBrowser x:Name="pdfWebViewer"></WebBrowser> In the constructor navigate to blank page: pdfWebViewer.Navigate(new Uri("about:blank")); To load a PDF document to that control use this simple code: pdfWebViewer.Navigate(fullPathToPDF); This approach is used by many Windows software not only WPF apps including SAP client, but has a hidden problem, see this question. The Adobe PDF Reader Addon in Internet Explorer must be enabled for this to work. There are various problems with Acrobat Reader XI, better to use DC version. To enable Adobe PDF go to IE settings, add-ons and find Adobe PDF Reader and enable it (AR XI and above...

Create A Hyperlink Using Xamarin.Forms (xaml And C#)

Answer : You can't really do this because Labels by default don't respond to user input, but you can achieve something similar with gestures using Xamarin.Forms; using Xamarin.Essentials; Label label = new Label(); label.Text = "http://www.google.com/"; var tapGestureRecognizer = new TapGestureRecognizer(); tapGestureRecognizer.Tapped += async (s, e) => { // Depreciated - Device.OpenUri( new Uri((Label)s).Text); await Launcher.OpenAsync(new Uri(((Label)s).Text)); }; label.GestureRecognizers.Add(tapGestureRecognizer); I made this little class to handle it: public class SimpleLinkLabel : Label { public SimpleLinkLabel(Uri uri, string labelText = null) { Text = labelText ?? uri.ToString(); TextColor = Color.Blue; GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(uri)) }); } } And a bit more involved if you want to underline it too: public class LinkLabel : StackLayout { pr...