I've two comboBoxes one above another. The problem appear if you open the form that contain this comboBoxes and avoid mouse over at lower comboBox, you just click on first comboBox and from drop down list choose item that is located right over the second comboBox. Once you click on an item the drop down list will close but your mouse will remain over the second comboBox. But this comboBox will not highlight and react on your clicks at all. Take a look at this picture please:
Both comboBoxes IsEditable = false; But if you move your mouse out of the 2nd comboBox and back over to it - everything will works fine. Help me please how to fix this.
UPD. XAML:
<ComboBox Background="{x:Null}" Height="33" HorizontalAlignment="Left" IsEditable="False" IsEnabled="True" Margin="10,151,0,0" Name="comboBox2" VerticalAlignment="Top" Width="239" VerticalContentAlignment="Center" FontSize="14" IsReadOnly="False" Text="" SelectionChanged="comboBox2_SelectionChanged" TabIndex="6" HorizontalContentAlignment="Left" Padding="10,3" FontWeight="SemiBold" AllowDrop="False" Cursor="Hand" IsTabStop="True" />
<ComboBox Background="{x:Null}" FontSize="14" Height="33" HorizontalAlignment="Left" IsEditable="False" IsEnabled="True" Margin="10,190,0,0" Name="comboBox3" VerticalAlignment="Top" VerticalContentAlignment="Center" Width="439" IsReadOnly="False" Text="" SelectionChanged="comboBox3_SelectionChanged" TabIndex="8" HorizontalContentAlignment="Left" Padding="10,3" FontWeight="SemiBold" ClipToBounds="False" Cursor="Hand" IsHitTestVisible="True" SnapsToDevicePixels="True" UseLayoutRounding="True" />
Set Background property to White or Transparent instead of {x:Null}. Null background affects control hit-test behavior.
Related
I am having a XAML issue and I am sure it's because of the fact that order matters in XAML.
The question is, how can I create the button after the control with the Selected event on it if the button is in another parent? Because XAML order matters, and the Selected event has in its C# method a button which is made AFTER the control with the Selected event, and so when the application starts, the button is null, I get this this exception:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
SettingsStartupUpdateCheckBtn was null.
In XAML I have this code to make the button starting from line 782,:
<Button x:Name="SettingsStartWithWindowsBtn"
BorderThickness="10"
Grid.Row="2"
Grid.Column="4"
Width="40"
Height="40"
Content="{DynamicResource off}"
FontSize="18"
FontWeight="DemiBold"
HorizontalAlignment="Center"
Focusable="False"
IsTabStop="False"
IsEnabled="True"
VerticalAlignment="Center"
BorderBrush="White"
Foreground="Red"
Click="SettingsButtons_Click"
Style="{DynamicResource RoundedCheckboxStyle}"/>
and I have this XAML code to make a ComboBox control at line 818:
<ComboBox x:Name="SettingsLanguageSelection"
BorderThickness="10"
Grid.Column="4"
Grid.ColumnSpan="1"
Grid.Row="0"
Width="100"
Height="30"
FontSize="16"
Focusable="False"
IsTabStop="False"
HorizontalAlignment="Center"
VerticalAlignment="Center"
BorderBrush="White"
Style="{DynamicResource ComboBoxFlatStyle}">
<ComboBoxItem x:Name="SettingsLanguageEnglish"
Content="{DynamicResource english}"
FontSize="15"
Focusable="False"
IsSelected="True"
Selected="SettingsLanguageEnglish_Selected"/>
<ComboBoxItem x:Name="SettingsLanguageRomanian"
Content="{DynamicResource romanian}"
Focusable="False"
FontSize="15" Selected="SettingsLanguageRomanian_Selected"/>
</ComboBox>
The Selected events go to a C# method that references the SettingsStartWithWindowsBtn button, which of course is null because it's created after the ComboBox control.
Now I don't know how to create the button before the ComboBox control if the button is in another parent in the XAML code.
Issue: I am unable to select the Richtextbox 'rtbx_COMMENTS' either using keyboard or mouse. Having tried and retried various properties and values for this control I am at a loss as to why this is not selectable
The controls useage is read only but it needs to be selectable so it can be vertically scrolled
I have manually added the properties IsEnabled="True" and Focusable ="True" into the XAML definition for the control as a belts and braces effort to try and get this control selectable. I even set the stackpanel as focusable wondering if the richtextbox was inheriting properties from it
In the codebehind, I use ONLY the follow to manipulate this control, clearing the control, appending text etc
rtbx_COMMENTS.Document.Blocks.Clear();
rtbx_COMMENTS.AppendText(_x.COMMENT);
where _x.COMMENT refers to a string, example being
"Select If : Gas Issue affecting every burner\r Smell of gas when appliance not in use"
and the XAML
<StackPanel x:Name="spnl_COMMENTS" Orientation="Horizontal" Margin="5,2.5,5,0" HorizontalAlignment="Center" VerticalAlignment="Center" Width="780" Focusable="True">
<Label x:Name="lbl_COMMENTS" Content="COMMENTS" Margin="5,1,0,0" BorderThickness="1" BorderBrush="#FF45CDDA" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="18" Foreground="#FFABA63A" Width="115" TabIndex="-1" Height="145"/>
<RichTextBox x:Name="rtbx_COMMENTS" IsEnabled="True" Focusable ="True" BorderBrush="#FF45CDDA" Padding="2" Margin="0,1,5,0" Background="{x:Null}" Foreground="#FFE48989" IsReadOnly="False" FontSize="16" MinWidth="655" Width="655" Height="145" TabIndex="19" IsHitTestVisible="False" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" MinHeight="145" IsDocumentEnabled="True" Cursor="Arrow" UseLayoutRounding="False" AllowDrop="False" IsTabStop="True" >
</RichTextBox>
</StackPanel>
Your IsHitTestVisible="False" property in XAML, causes the problem of not selecting the text in rich text box.
I have a AutoCompleteBox control in my wpf application. I do not want to allow a value drop in it. I have bound AllowDrop=False but still I am able to drop values on it. Same is working very fine for my textbox. Can some one help.
here is my code:
<Control:AutoCompleteBox
Name="selectCountry"
Grid.Row="2"
Grid.Column="1"
Height="22"
MinWidth="80"
MaxWidth="80"
FilterMode="Contains"
HorizontalAlignment="Left"
IsEnabled="{Binding xxx}"
ItemsSource="{Binding xxx}"
SelectedItem="{Binding xxx, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"
Text="{Binding xxx}"
ValueMemberPath="xx"
AllowDrop="False"
>
Basically, we have created our own custom MultiSelect-ComboBox using Telerik's RadComboBox and the SelectionBoxTemplate to make the custom text appear when multiple items are selected.
<ucControls:MultiSelectComboBoxBase
... >
<ucControls:RadComboBox
x:Name="RadCombo"
Text=""
Height="22"
HorizontalContentAlignment="Left"
HorizontalAlignment="Stretch"
DropDownClosed="RadCombo_DropDownClosed"
IsTextSearchEnabled="False"
IsEnabled="{Binding IsEnabled}"
CanAutocompleteSelectItems="False"
CanKeyboardNavigationSelectItems="False"
LostFocus="RadCombo_LostFocus">
<ucControls:RadComboBox.SelectionBoxTemplate>
<DataTemplate>
<Grid Background="Aqua">
<TextBlock x:Name="ComboBoxDisplay" Text="{Binding Text, ElementName=RadCombo}" />
</Grid>
</DataTemplate>
</ucControls:RadComboBox.SelectionBoxTemplate>
<ucControls:RadComboBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<CheckBox x:Name="chkBox"
Content="{Binding ItemValue}"
Tag="{Binding ItemID}"
Height="16" Margin="2"
IsChecked="{Binding IsChecked, Mode=TwoWay}"
Visibility="{Binding IsSelectAllItem, Converter={StaticResource booleanToVisibilityConverter}, ConverterParameter=NOT}"
HorizontalAlignment="Stretch" VerticalAlignment="Top"
Checked="ChkBox_Checked" Unchecked="ChkBox_Unchecked"
IsEnabled="{Binding IsEnabled, Mode=TwoWay}"/>
<HyperlinkButton
VerticalAlignment="Center" Content="{Binding ItemValue}"
Visibility="{Binding IsSelectAllItem, Converter={StaticResource booleanToVisibilityConverter}}"
Style="{StaticResource HyperlinkButtonNoBorderStyle}" Margin="3,2,0,0"
Click="HyperlinkButton_Click"
IsEnabled="{Binding IsEnabled, Mode=TwoWay}" />
</StackPanel>
</DataTemplate>
</ucControls:RadComboBox.ItemTemplate>
</ucControls:RadComboBox>
It works great, but the only problem is that it appears that the SelectionBoxTemplate isn't actually applied when the radcombobox is loaded. It only applies when the box is clicked.When it loads it displays:
Then you click and it displays the dropdown:
Then you click away and it displays the correct text from the SelectionBoxTemplate:
Note I made the background color of the Textblock blue, just to show that it does not apply on the initial load.Ideally, when it loads it should automatically apply the SelectionBoxTemplate and display the correct information rather than having the click and then click away from the multiselectcombobox. Also, the TextBlock text is bound to the RadComboBox's text because in the code behind we set the RadComboBox's text. There is no issue with null values or the Text not being set before because I've looked in debugging mode and all the information is there, the selection box template is just not being applied until the box receives focus. Is there some sort of event that has to fire off before the template is applied, or is there someway I can force the template to be applied onload?
I had the same issue as you. I've managed to solve it by setting the SelectedIndex="0"
I've also read that the SelectionBoxTemplate only works when the RadComboBox is not editable: IsEditable="False"
<ucControls:RadComboBox
x:Name="RadCombo"
SelectedIndex="0"
IsEditable="False"
Height="22"
HorizontalContentAlignment="Left"
HorizontalAlignment="Stretch"
DropDownClosed="RadCombo_DropDownClosed"
IsEnabled="{Binding IsEnabled}"
LostFocus="RadCombo_LostFocus">
...
</ucControls:RadComboBox>
I have a C# WPF app where there are some buttons on top to perform functions like table lookup or maintenance here:
<Border Grid.Row="0" CornerRadius="5" BorderBrush="AliceBlue" Margin="10" VerticalAlignment="Top" >
<StackPanel Orientation="Horizontal" Height="35" >
<Button Content="Upload File" Margin="0,0,3,0" Command="{Binding CmdUploadFileCtrl}" Width="100"></Button>
<Button Content="Medicine Price" Margin="0,0,3,0" Command="{Binding CmdMedicinePriceCtrl}" Width="100"></Button>
<Button Content="NDC Discounts" Margin="0,0,3,0" Command="{Binding CmdNDCDiscountCtrl}" Width="100"></Button>
<Button Content="Facility" Margin="0,0,3,0" Command="{Binding CmdFacilityCtrl}" Width="100"></Button>
</StackPanel>
</Border>
<sdk:DataGrid
Grid.Row="1" x:Name="dgFacility"
SelectionMode="Single"
SelectedItem="{Binding Path=SelectedItemFacility, Mode=TwoWay}"
ItemsSource="{Binding Path=LstFacility, Mode=TwoWay}"
AutoGenerateColumns="False"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
AllowDrop="False">
When user presses Facility tab it goes there, but when then tried to 'Upload file' that button is become disabled. How can I prevent this disabling?
Since the buttons are bound to commands, there should be code (somewhere) that is determining when the buttons are enabled/disabled.
Depending on what type of commanding is being used you may have a method named something like CanUploadFileCtrl or CmdUploadFileCtrl_CanExecute which returns true/false.