I have designed a Window in WPF that has 2 web browser controls. Each one has its own scroll bar. Touch events work for scrolling until I want to scroll them at same time.
<Grid x:Name="grid1">
<DockPanel x:Name="DockLeft" HorizontalAlignment="Left">
<WebBrowser></WebBrowser>
</DockPanel>
<DockPanel x:Name="DockLeft" HorizontalAlignment="Right">
<WebBrowser></WebBrowser>
</DockPanel>
</Grid>
How it is possible to have two isolated areas for touch event?
You need to override Touch event on both WebControls(in event you have access to finger motions etc..) and provide custom logic there. Should be little work, but it should be ok.
Related
I'm writing a WPF desktop application, with some video playback functions. I decided to use LibVLCSharp.WPF to complete the playback task.
Xaml code:
<UserControl ...
xmlns:vlc="clr-namespace:LibVLCSharp.WPF;assembly=LibVLCSharp.WPF"
... >
<vlc:VideoView VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<Canvas VerticalAlignment="Stretch" HorizontalAlignment="Stretch" MouseEnter="Canvas_MouseEnter">
</Canvas>
</vlc:VideoView>
</UserControl>
It works fine with playing video, but when I tried to put some hidden controls inside Canvas (or any other type of Panel control) and change their visiblity with MouseEnter event, nothing happens.
While debugging, I found out that MouseEnter event can only fire when Canvas has at least one visible control as its child, and mouse pointer entered that visible control.
I have read the articles about "airspace issue". It seems nothing to do with me since I just want to draw a control layer exactly inside playback area.
Is there any way that I can put an auto show panel on VLC player, which only shows when mouse "hovered" over playback area?
Problem solved with hint from #cube45 . Thank you.
I changed Background of Canvas to something that "not so transparent".
Xaml code:
<Canvas Background="#01000000" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" MouseEnter="Canvas_MouseEnter">
</Canvas>
And mouse events worked. Tricky, but useful.
I'm working on updating previously working app. Testing shows the ScrollViewer acting oddly when the Zoom makes part of the contained images fall off the screen. The original app was created with VS 2013 as a Universal Windows app. The new app is created with VS 2015 as a Universal Windows app though the target build has been shifted to the anniversary release.
My XAML is defined so:
<ScrollViewer x:Name="SV1" Grid.Row="1" HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto"
SizeChanged="SV1_SizeChanged" ZoomMode="Enabled" >
<StackPanel x:Name="ImagePanel" Orientation="Horizontal" HorizontalAlignment="Center"
VerticalAlignment="Top" >
<Image x:Name="ImageLeft" Stretch="Uniform" />
<Image x:Name="ImageRight" Stretch="Uniform" />
</StackPanel>
</ScrollViewer>
The user can change the ZoomLevel of the ScrollViewer. The zoom change is implemented using SV1.ChangeView(null, null, zoomFactor).
The images visibly change size on the screen, but as they fall off the right or bottom the scrollbars don't appear. Even changing the visibility properties to "Visible" instead of "Auto" doesn't cause the scrollbars to appear. When the size changes and for a brief instant a thin line will appear where the bars should be and then disappear. Additionally, user input that would normally scroll like moving the mouse wheel does nothing.
Based on other commentary, I've tried replacing the StackPanel with a Grid with no apparent effect.
I'm drawing a blank. Any ideas?
It appears the answer is the next control which shares the same visual space needs to be set to Visibility="Collapsed" in the XAML. The visibility is controlled programmatically, but without the XAML tag the scrollbars of the previous control don't appear and with the tag they do.
I have a borderless transparent (rounded corners) WPF Window. It is a fairly complex app with a lot of dialogs that can be shown or hidden. We do this via MVVM binding to the Visibility property using the BooleanToVisibilityConverter which, as far as I am aware, set the visibility to Visible or Collapsed accordingly.
When I resize the window I get a significant lag in the drawing of the window that tends to leave content (borders, framework elements) behind (in that they dont follow the resize very fast). So to clarify I have the main window and the content inside of it (the content is inside a border). The main window will follow the mouse on resize accurately but the content will follow very slowly and will jerk.
I can't figure out what it is, can anyone offer any assistance? Obviously I am assuming that Collapsed dialogs are not resized (or relocated) when the window resizes.
Here is a little example of how we setup a dialog within the Main Window
<Grid x:Name="GlobalModalBackground" Visibility="{Binding ShowGlobalModalBackground, Converter={StaticResource BoolToVisibilityConverter}, FallbackValue=hidden}" Grid.ColumnSpan="2">
<Border CornerRadius="3" Background="#66000000" Opacity="{Binding ModalOpacity}" />
<Grid>
<local:About x:Name="AboutDialog" DataContext="{Binding AboutViewModel}" HorizontalAlignment="Center" VerticalAlignment="Center" Height="300" Width="500"/>
<!-- Other dialogs here -->
In this case, the AboutDialog itself will take care of showing itself or closing itself based on what its ViewModel is set to.
I am using the Fluidkit ElementFlow control that I use to display a UserControl that contains textblock with a ScrollViewer as well as button and when they are displayed in the ElementFlow control, all of the buttons and the ScrollViewer seem to be disabled because I can't scroll the ScrollViewer scrollbar and even a simple action as hovering over a button doesn't do anything to the button.
Below is an example of the TextBlock in a ScrollViewer that does not allow for scrolling when used in the ElementFlow.
How can this be fixed?
<ScrollViewer
Height="1200" Width="800"
MaxHeight="1200" MaxWidth="800"
VerticalScrollBarVisibility="Auto">
<TextBlock
Height="Auto" Width="800"
MaxWidth="800"
FontSize="20"
Text="Super long text"
TextWrapping="Wrap"/>
</ScrollViewer>
Just looking over the source code for the project, it looks like it is creating a 3D mesh, and painting the controls on the mesh. This would prevent all user interaction. I don't think there is an easy way to work around this.
However, since you have the source code, you can do the work yourself to make it happen. You're going to need to modify how the ElementFlow represents its items. Look at the CreateMeshModel function. It is currently creating a mesh and applying a VisualBrush to it. Instead, look at the blog post Interacting with 2D on 3D in WPF to figure out what needs to happen.
I have this:
<Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<StackPanel Orientation="Horizontal">
<StackPanel Width="100" Margin="20">
<CheckBox x:Name="cbFoo1" Content="Foo"/>
<TextBlock Text="Foo"/>
<TextBox />
</StackPanel>
<StackPanel Width="100" Margin="20">
<CheckBox x:Name="cbFoo2" Content="Foo"/>
<TextBlock Text="Foo"/>
<TextBox />
</StackPanel>
</StackPanel>
<Rectangle Fill="#BF000000" x:Name="rOverlay"/>
</Grid>
</Window>
I want to make a function foo with argument argControls() that makes rOverlay cover every control in the window except argControls(). Does anyone have any idea how to do this?
What about setting the visibility of the control to Collapsed when you want to hide them.
Option 1 - Draw Order
While a bit of a hack, perhaps the simplest way to accomplish this is to place controls that you wish covered before the rectangle and controls that you wish visible after the rectangle.
One step better (and not a hack) would to use the Panel.ZIndex property instead. This allows you to control the order that the UI elements are drawn regardless of the order that they are defined. This would be accomplished by setting the Panel.ZIndex as follows:
rOverlay to some arbitrary value (like 1)
controls to be covered to something lower than rOverlay (like 0)
controls to be visible to something higher than rOverlay (like 2)
It should however be noted that any transparent regions of your controls will still display the black rectangle behind them. This can either be specifying a background colour or by using another option presented here.
Option 2 - Clipping
Another more complex method involves setting the Clip property of the rectangle to a geometry that only includes the regions that you wish filled. This would likely be accomplished by using an instance of CombinedGeometry class with the CombineMode of Exclude. This would prevent the rectangle from drawing anything over regions outside the clipped region.