Everybody,
I am stuck with a wiered issue since yesterday .
I've searched all the forums , blah blah blah.....
No Luck Yet...
I am making a WPF windows Desktop Application using WPF Ribbon Control .
I created and deployed the whole application on my machine
VS2015.
Windows 8.1 64Bit.
All worked perfect.
But When I deployed it on a Windows 7-32Bit Machine.
It started throwing exception at start of the application. I've put try catch around InitializeComponents(); It throws Error
here is my simplified code,
<Grid>
<Grid.Resources>
<BitmapImage x:Key="PasteImageResource" UriSource="/Images/paste.png" />
<BitmapImage x:Key="AddImageResource" UriSource="/Images/add.png" />
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<DockPanel x:Name="UiPanel" ScrollViewer.VerticalScrollBarVisibility="Visible" Grid.Row="1" />
<Ribbon x:Name="MainRibbon" RenderTransformOrigin="0.9,0.797" >
</Ribbon>
</Grid>
The problem i found is due to Ribbon Control. As soon as i remove the line (i.e)Ribbon TAg
The error goes away. I've tried to debug and found that the inner exception is saying that
Cannot have nested BeginInit calls on the same instance
Looking for help ..........
Related
is any way to open a web browser(visible?) in specific browser and do action like clic button, search etc. i try
WebBrowser web = new WebBrowser();
web.Navigate(new Uri("https://www.google.com/"));
but i didnt see it. I too know i can do something like that
System.Diagnostics.Process.Start("chrome.exe","http://www.google.com");
but how then make action there control it? Or the only way is open browse in wpf and show it on some king of window.
The best place to actually start learning how to utilize the different Class Controls at our disposal from the .NET environment is reading their documentation!
WebBrowserClass
They show a relative simple example of how to achieve what you want, with the creation of the webbrowser in XAML. In this XAML, they define a TextBox so you can introduce your absolute path, but also a button to perform the search when you click on it.
<Grid x:Name="MainGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBox x:Name="addressTextBox" Width="200" />
<Button Click="Button_Click">Go</Button>
</StackPanel>
<WebBrowser Grid.Row="1" x:Name="myWebBrowser" />
</Grid>
I changed the XAML part a bit, so you don't have your WebBrowser with limited Height and instead have it occupied most of the screen real estate.
PS. In all honesty i cannot pinpoint why your code-behind implementation on the WebBrowser is not working though.
Recently Xamarin.Forms changed its behavior for controls with Clear and Default background. The changes are described in this PR: https://github.com/xamarin/Xamarin.Forms/pull/935
This change was quite a breaking change in two of my apps. The default XAML behavior in UWP and WPF is that when Background is clear (x:Null), the visual is click-through, but If it has some children, you can still interact with them. This is very important especially for mapping apps where you often need map control and then layout some control above it. If I set the layer to InputTransparent user cannot interact with any controls in the layer in any way, if I don't set it, then I cannot interact with the map itself.
The problem is that I don't see any easy workaround to this, because I cannot layout the controls without a layout parent. If I want to lay them out in a grid, I need a Grid above them. and that will block the map. Same with any other layout.
I want to achieve something like the following:
<CustomMapControl />
<Grid x:Name="ControlsGrid">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button Grid.Row="1" Text="Zoom in" />
</Grid>
<AboluteLayout x:Name="PlaceMenuContainer" />
This code now will not allow me to interact with the map, because the Grid occludes it. If I add InputTransparent="True" to the Grid, I cannot interact with the button anymore, as the touch interactions are no longer dispatched to them (see VisualInputRenderer, line 52 - 64). Also note that I can have multiple layers above the map, like the PlaceMenuContainer which is a container for context menu items which are displayed above the map when the user taps a certain location on the map. This means I cannot easily use a single layout container for all controls...
Do you see any way around this?
I got a confirmation from E. Z. Hart from the Microsoft Xamarin Team that this issue is currently looked at, and that several developers have run into this problem. Either a workaround of a new approach will be implemented soon, any updates will be posted on the related bug in Bugzilla :-).
Did you try something like
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<CustomMapControl Grid.RowSpan="2"/>
<Button Grid.Row="1" Text="Click me" />
</Grid>
This problem does not impact WinForms.
I have downloaded the bare minimum example from the github site:
https://github.com/cefsharp/CefSharp.MinimalExample
As far as I am reasonably aware everything is up-to-date - I have used NuGet to make sure the latest CefSharp.Common, CefSharp.Wpf etc have been installed - currently version 53.
When I use it to browse web pages it's fine. The problem is when I attempt to view a PDF-based page eg:
http://www.cbu.edu.zm/downloads/pdf-sample.pdf
So in the MainWindow.xaml I bind the 'Address' property to this value instead of "www.google.com":
<Window x:Class="CefSharp.MinimalExample.Wpf.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wpf="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
Title="{Binding Path=Title, ElementName=Browser, Converter={StaticResource TitleConverter}}"
WindowState="Maximized">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<wpf:ChromiumWebBrowser Grid.Row="0"
x:Name="Browser"
Address="http://www.cbu.edu.zm/downloads/pdf-sample.pdf" />
<StatusBar Grid.Row="1">
<ProgressBar HorizontalAlignment="Right"
IsIndeterminate="{Binding IsLoading, ElementName=Browser}"
Width="100"
Height="16"
Margin="3" />
<Separator />
<!-- TODO: Could show hover link URL here -->
<TextBlock Text="{Binding Address, ElementName=Browser}"/>
</StatusBar>
</Grid>
When I run the example, in order to navigate to this PDF, the screen remains blank and the progress control does not update:
... unless I do something like un-maximise the browser window, or move it etc, then I can view it:
After this there is another strange problem whereby the scrollbars and +/- buttons appear to be unresponsive. I notice that if I do press the '+' button for example and then another action such as maximize/restore - then the intended '+' action appears to have been carried out. Ditto the scrollbar and other actions.
It does not exhibit this behaviour for the WinForms minimal example, if this helps, only the Wpf.
Any suggestions greatly appreciated.
This has been raised as a duplicate of issue #1799 over at the GitHub site:
WPF/OffScreen PDF Viewer not working #1799
Until Version 55 is released, the solution as stated on the site is:
"Suggested workaround is to call Invalidate() on a timer as proposed on ceforum
You can roll back to 51 and use disable-surfaces or wait for version 55 to be released."
I found that rolling back to a previous version worked for me.
UPDATE 21 Jan 2019
This is no longer an issue with the more recent versions of CefSharp.
I want to create a WPF control which looks like control which appears while we debug .NET code. I.e. control like the window which shows all the property/value and have top and bottom arrow, clicking on which list scrolls up/down. (I am looking for control which have Scroll bar in this style).
To be more specific, I want to make a control like a Panel in which I can display controls/text and which have sroll button in middle like it appears in debug window as shown in Image link.
Link is having sample of control I am trying to make.
http://www.use.com/supersize.pl?set=11a2085f136b99d6869c
Any help will be appreciated.
It sounds like you want to use the WPF Visualizer that comes with Visual Studio. You can access it in debug mode once execution has hit a break point. It displays every property and value for every item in the visual tree. You can find out more from the How to: Use the WPF Tree Visualizer page on MSDN.
The control you wanted probably like this
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="*"/>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<RepeatButton>Up</RepeatButton>
<ScrollViewer Grid.Row="1" x:Name="sv" VerticalScrollBarVisibility="Hidden">
<Rectangle Height="700" Fill="Black"/>
</ScrollViewer>
<RepeatButton Grid.Row="2">Down</RepeatButton>
</Grid>
also you should control scrollview in codebehind via click eventhandler of RepeatButton.
I have created a simple control SimpleControl.xaml in C++/CX defined as:
<UserControl .. > // Attributes omitted for reading simplicity
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image x:Name="PersonaPicture" ... />
<Border x:Name="PhotoTextBackdrop" ... />
<TextBlock x:Name="PersonaName" .../>
</Grid>
</UserControl>
Then this control is used in the following manner in a file “foo.xaml” that uses C++/CX as a code behind. SuperPanel inherits from Windows.UI.Xaml.Controls.Panel and is defined in the TastyLib component (consumed by this C++/CX component). The 'fruity' namespace points to TastyLib. The TastyLib component is coded in C#:
</fruity:SuperPanel>
<local:SimpleControl x:Name="gPerson1" Grid.Row="0" Grid.Column="0" />
<Rectangle Fill="SaddleBrown" Height="50" Width="50" Grid.Row="1" Grid.Column="0" />
<UserControl Grid.Row="2" Grid.Column="0" />
</fruity:SuperPanel>
Setting a breakpoint and looking at the watch , I observed the following to be the children of the panel:
child[0] was Windows.UI.Xaml.UIElement, child[1] was
Windows.UI.Xaml.Shapes.Rectangle and child[2] was
Windows.UI.Xaml.Controls.UserControl
Now, in the watch I was expecting the first child to be a SimpleControl, but instead it is a UIElement, which is surprising to me. Where did that come from? Why is it showing an ancestor of SimpleControl as child[0] while it can still recognize a UserControl as child[2] ?
I recreated another SimpleControl in a C# component that uses TastyLib (So this SimpleControl was also written in C# and did not use C++/CX), and put that control within another SuperPanel, exactly like the first case (but all in C# this time). On setting the same breakpoint and viewing in the watch window I saw child[0] to be what I was expecting - a SimpleControl. In this case:
child[0] was FooProject.SimpleControl, child[1] was Windows.UI.Xaml.Shapes.Rectangle and child[2] was Windows.UI.Xaml.Controls.UserControl
What could be the root cause of this dichotomy? Shouldn’t a control written in C++/CX behave the exact way as a control written in C# (when consuming the same component written in C#) ? I’m guessing that it’s something to do with component interoperability. Has anyone faced a similar problem?
Any advice would be appreciated.
Many thanks.
From the research I've done, the issue is that a winRT boundary is crossed in the case of the control written in C++/CX so when the CLR asks for the type, the object returns back Windows.UI.Xaml.UIElement from its GetRuntimeClassName implementation (why?).
In case of control developed using C#, no winRT boundry is crossed and a .NET object is speaking to another .NET object and hence the type is known.