Visual Studio's IntelliSense keeps blowing up at me when I try to set a vertical scrollbar on my textbox with C#. It says that 'TextBox' has no definition for Scrollbars and suggests that I'm missing something.
I think I must be missing something because everything I find online just assumes it works by typing txtMyTextBox.Scrollbar = true; but it doesn't work for me. I don't really know what I'm doing wrong. I haven't added any using statements, just the default that get loaded when using WPF, but no tutorials ever point to me needing to add one.
<TextBox
Height="200"
AcceptsReturn="True"
Text="{Binding ... }"
TextWrapping="Wrap"
VerticalScrollBarVisibility="Visible" />
Related
So I have a project where I am setting up a resource variable named TEST (Right clicking on the project in the Solution Explorer, choosing Properties, then choosing Resources) and I want to pass those into a textbox on a WPF XAML form. It seems to be different than if I try to use a normal variable but alas, I am befuddled.
Can anyone guide me please on how to pass the variable thru please?
Thank you.
I know this is not the correct method
======================================
<TextBlock Text="{Binding Bottle_1_Title}" FontWeight="Bold" FontSize="32" HorizontalAlignment="Center" TextAlignment="Center"></TextBlock>
This is also not valid and I am not seeing the intellisense to help me
<TextBlock Text="{resource.test}"
I have a TabControl (using InfragisticTabControl) where each TabItem contains a WebBrowser control where I can display a URL like www.google.com or any xbap UI.
Below is the TabItem Code:
<Grid>
<WebBrowser x:Name="myBrowser"
webHelper:WebBrowserHelper.BrowserSource="{Binding XBAP_URI}"
Height="Auto"/>
<Grid Name="MyOverlayGrid" Background="LightGray" Opacity="0.5"
Visibility="{Binding Path=IsEnabled, Converter={StaticResource BoolToVisible2}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type igDock:ContentPane}}}">
<TextBlock Text="User does not have permissions for this application" FontSize="24"/>
</Grid>
</Grid>
I verified using snoop that Visibility binding is correctly getting populated, but I don't see MyOverlayGrid on myBrowser control. I even tried updating Panel.ZIndex for MyOverlayGrid, no help.
Only thing that worked is to set myBrowser visibility to hidden (i used snoop) and then i could see MyOverlayGrid.
Can anyone tell me if I am doing something incorrect or missing something obvious? This works fine for a contentcontrol, may be its not possible for a WebBrowser control since the its starts new applictaion (InternetExplorer.exe or PresentationHost.exe) in the tab control?
Thanks,
RDV
Can anyone tell me if I am doing something incorrect or missing something obvious?
The latter am I afraid. The WebBrowser control is hosted in a separate HWND that is always drawn on top of the WPF elements as stated in the documentation on MSDN: https://msdn.microsoft.com/en-us/library/ms744952(v=vs.110).aspx.
There is nothing much you can do about this besides applying a workaround like for example putting your Grid in a Popup.
You may want to consider using some other third-party WebBrowser control such as for example Chromium.
I'm trying to get a ScrollView to logical scroll instead of physically. After reading up online on how to do this, most sources say to set the CanContentScroll property to False. However, when attempting to do this, it seems that ScrollViewer doesn't have this property.
Here is my XAML code:
<ScrollViewer x:Name="TestScroll" CanContentScroll="True" HorizontalScrollBarVisibility="Disabled" HorizontalScrollMode="Disabled" Margin="66,215,1020,10" Grid.Row="1">
<StackPanel x:Name="TestPanel" Orientation="Vertical">
</StackPanel>
</ScrollViewer>
And the error(s) thrown:
Error 1 The member "CanContentScroll" is not recognized or is not accessible.
Error 2 The property 'CanContentScroll' was not found in type 'ScrollViewer'
I am developing for Windows 8.1, creating a universal app. I feel like I'm missing something like a reference or something incredibly simple because everywhere else that I have looked, it just works.
Any help would be appreciated.
Figured it out, using the VerticalSnapPointsType="Mandatory" property for ScrollViewer instead.
I have a boolean property in my ViewModel, named lets say IsNotSupported that is used to show some warning information if a sensor is not supported. Therefore I use a BooleanToVisibilityConverter, that is added in the ressources:
<phone:PhoneApplicationPage.Resources>
<local:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
</phone:PhoneApplicationPage.Resources>
and bind it to the stackpanel containing the warning:
<StackPanel x:Name="NotSupportedWarning" Visibility="{Binding IsNotSupported,
Converter={StaticResource BooleanToVisibilityConverter}}">
That works all quite well, but when loading the page, and the sensor is supported, the warning appears for just a fraction of a second and disappears afterwards. I know that this flickering is caused by the binding not having happened yet and therefore defaulting to visible.
That flicker it is annoying as hell... It should rather default to collapsed and be made visible only after it is clear that the warning should be shown. Also, this would avoid a second layouting pass after the binding and could therefore have positive performance impacts.
I had this problem over and over, and found nothing about it in the internet until I found this SO question, that is closely related, but is not found if searched for windows phone instead of silverlight. Both the problem and the solution might seem simple, but I really bugged me quite a long time, so I thought it might be a good idea to write a Q&A-style question about it to help others that are facing the same issue.
The solution is simple after you have seen it. You can control the default value of the binding (if the binding didnt happen yet) with FallbackValue. Your stackpanel XAML would look like:
<StackPanel x:Name="NotSupportedWarning" Visibility="{Binding IsNotSupported,
FallbackValue=Collapsed,
Converter={StaticResource BooleanToVisibilityConverter}}">
This way you get rid of the flicker and it does not have to be relayouted after the binding, if the warning stays hidden.
you can bind directly to a Visibility type of property instead of boolean and keep that property to collapsed by default plus you can implement INotifyPropertyChanged
Please forgive this stupid question. (I'm originally an ASP.NET programmer.)
I'm trying to add a telerik context menu to a textbox control in the code behind.
Adding it in the xaml is very easy (this works)
<TextBox AcceptsReturn="True" Text="{Binding Mode=TwoWay, Path=Description}" TextWrapping="Wrap" x:Name="txtIssues" Width="280" Height="100" VerticalScrollBarVisibility="Auto">
<telerikNavigation:RadContextMenu.ContextMenu>
<telerikNavigation:RadContextMenu x:Name="contextMenu"
ItemClick="ContextMenuClick">
<telerikNavigation:RadMenuItem Header="Set Vista as Background" />
<telerikNavigation:RadMenuItem Header="Set Beach as Background" />
<telerikNavigation:RadMenuItem Header="Set Forest as Background" />
</telerikNavigation:RadContextMenu>
</telerikNavigation:RadContextMenu.ContextMenu>
</TextBox>
However I would like to completely add the the control from c# code and I can't find a why to add a control to a textbox. I've been looking for something like "txtIssues.Children.Add" but there doesn't seem to be an option.
First its best you understand that you are not adding a control to the TextBox. The RadContextMenu.ContextMenu is not a control it is an attached property.
Funnily enough the Telerik documentation describes adding a context menu to a textbox in C#. See Working with the RadContextMenu. Sometimes "RTM" is actually good advice.