How can I specify a Custom Popup Position ?
You can specify a custom pop-up location by setting the Placement property to Custom. This can be done with the following code snippets. [XAML] <Popup Name="myCustomPopup" PlacementTarget ="{Binding ElementName=myGridLayout}" Placement="Custom"> <TextBlock Height="50" Width="150" Background="LightGray" TextWrapping="Wrap">Custom popup position demo</TextBlock> </Popup> [C#] public CustomPopupPlacement[] placementForPopup(Size popupSize, Size targetSize, Point offset) { CustomPopupPlacement customPlacement1 = new CustomPopupPlacement(new Point(-40, 90), PopupPrimaryAxis.Vertical); CustomPopupPlacement customPlacement2 = new CustomPopupPlacement(new Point(20, 30), PopupPrimaryAxis.Horizontal); CustomPopupPlacement[] customPlacements = new CustomPopupPlacement[] { customPlacement1 , customPlacement2 }; return customPlacements ; } [C#] myCustomPopup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(placementForPopup); Reference link: https://docs.microsoft.com/en-us/dotnet/framework/wpf/controls/how-to-specify-a-custom-popup-position
How do I support drag-and-drop for a RichTextBox?
You must set the ‘AllowDrop’ property on the RichTextBox control to true and also handle both the ‘DragEnter’ and ‘DragDrop’ events. Add event handlers to the control as given below. [C#] using System.Windows.Forms; richTextBox1.DragEnter += new DragEventHandler( richTextBox1_DragEnter ); richTextBox1.DragDrop += new DragEventHandler( richTextBox1_DragDrop ); Write event handlers : { private void richTextBox1_DragEnter(object sender, DragEventArgs e) { e.Effect = e.Data.GetDataPresent(DataFormats.Text) ? DragDropEffects.Copy : DragDropEffects.None; } private void richTextBox1_DragDrop(object sender, DragEventArgs e) { // Load the file into the control string text = (string)e.Data.GetData('Text'); richTextBox1.LoadFile(text, RichTextBoxStreamType.RichText); } public Window1() { InitializeComponent(); } }
How do I detect permission for a file in a partial trust application ?
This situation occurs when an assembly is used by both windows and XBAP application in a partial trust. The assembly might have permission when used through windows application and the same when used through XBAP application will throw a security exception. To prevent this situation, the permission for a file can be checked using the ‘Demand()’ method on the instance of the desired permission. If a file doesn’t have permission, the Demand() method throws a security exception, else it can be used by the partial trust application.
Can I add prerequisites in my ClickOnce deployment ?
Yes. ClickOnce allows you to add prerequisites in ClickOnce deployment. It should download the installer packages for those prerequisites to your development machine. When you publish the ClickOnce application, choose Download prerequisites from the same location as my application. An error will occur if the installer packages aren’t in the Packages folder. Reference link: https://docs.microsoft.com/en-us/visualstudio/deployment/how-to-include-prerequisites-with-a-clickonce-application
How to Get or Set a value that indicates whether to include the DataErrorValidationRule ?
Setting this property provides an alternative to use the DataErrorValidationRule element, explicitly. The DataErrorValidationRule is a built-in validation rule that checks for errors that are raised by the ‘IDataErrorInfo’ implementation of the source object. If an error is raised, the binding engine creates a ValidationError with the error and adds it to the ‘Validation.Errors’ collection of the bound element. The lack of an error clears this validation feedback, unless another rule raises a validation issue. This example shows how to implement validation logic on a custom object and then bind to it. You can provide validation logic on the business layer if your source object implements IDataErrorInfo, as in the following example. In the following example, the ‘text’ property of the textbox binds to the ‘Age’ property of the Person object which has been made available for binding through a resource declaration that is given in the x:Keydata. The ‘DataErrorValidationRule’ checks for the validation errors raised by the IDataErrorInfo implementation. [XAML] <TextBox Style='{StaticResource textBoxInError}'> <TextBox.Text> <!--By setting ValidatesOnExceptions to True, it checks for exceptions that are thrown during the update of the source property. An alternative syntax is to add <ExceptionValidationRule/> within the <Binding.ValidationRules> section.--> <Binding Path='Age' Source='{StaticResource data}' ValidatesOnExceptions='True' UpdateSourceTrigger='PropertyChanged'> <Binding.ValidationRules> <!--DataErrorValidationRule checks for validation errors raised by the IDataErrorInfo object.--> <!--Alternatively, you can set ValidationOnDataErrors='True' on the Binding.--> <DataErrorValidationRule/> </Binding.ValidationRules> </Binding> </TextBox.Text> </TextBox>