Posts

Showing posts with the label wpf

How to get row value from datagrid using VB in WPF

Image
Clash Royale CLAN TAG #URR8PPP How to get row value from datagrid using VB in WPF I have populated the database table in my data grid. Now I want to get the either of the row value when i click on any of the data. I tried few examples which was in c# but it did not worked for me. The event I am using now is datagrid_SelectionChanged datagrid_SelectionChanged There were few examples which was using the DataGridView in my application I cant use the DataGridView. I even tried this sample from here but it didnt helped me either. DataGridView Can someone please help me to guide on solving this problem. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Adding Text and Value to ComboBox in WPF Application

Image
Clash Royale CLAN TAG #URR8PPP Adding Text and Value to ComboBox in WPF Application Following code is okey in vb.net and Windows Form Application. Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim comboSource As New Dictionary(Of String, String)() comboSource.Add("1", "Sunday") comboSource.Add("2", "Monday") comboSource.Add("3", "Tuesday") comboSource.Add("4", "Wednesday") comboSource.Add("5", "Thursday") comboSource.Add("6", "Friday") comboSource.Add("7", "Saturday") ComboBox1.DataSource = New BindingSource(comboSource, Nothing) ComboBox1.DisplayMember = "Value" ComboBox1.ValueMember = "Key" End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ...

Adding Controls into Xaml through C# Code, Performance Concerns

Image
Clash Royale CLAN TAG #URR8PPP Adding Controls into Xaml through C# Code, Performance Concerns I'm Newbie in WPF and i want to know if is there any performance issue when i add a Child into a Container from C# codes in WPF instead of adding it in the XAML? I have so many control manipulation in my project and it's important to know to for me if i must try to design UserControls and design ControlTemplates to get the better performance. UserControls ControlTemplates for example i want to know if I add each the records in my List, manually by iterating it and creating a the rows; does it takes more cost of executing than Binding it to predefined grid (rows, ...) Template ? Binding does Binding s makes my code fast in runtime? Binding What stops you from trying it out? That said, what you're describing sounds like you should be using an ItemsControl instead of manually creating list items. – Clemens 2 mins ago ...

WPF: The toolbar is a keyboard trap

Image
Clash Royale CLAN TAG #URR8PPP WPF: The toolbar is a keyboard trap I have the following XAML code: <ToolBarTray DockPanel.Dock="Top"> <ToolBar VerticalAlignment="Top"> <ComboBox x:Name="ComboboxFontname" ToolTip="Auswahlliste um Schriftart festzulegen" ItemsSource="{x:Static Fonts.SystemFontFamilies}" SelectedIndex="0" Width="200" GotFocus="ComboBox_GotFocus" LostFocus="ComboBox_LostFocus"/> <ComboBox x:Name="ComboboxFontsize" ToolTip="Auswahlliste um Schriftgröße festzulegen" SelectedIndex="0" Width="45" GotFocus="ComboBox_GotFocus" LostFocus="ComboBox_LostFocus"> <ComboBoxItem Content="12"/> <ComboBoxItem Content="14"/> <ComboBoxItem Content="16"/> ...

TextWrap in StackPanel

Image
Clash Royale CLAN TAG #URR8PPP TextWrap in StackPanel I have a UserControl which a couple of buttons and some Textblock's. For some reason, the TextWrap is not working for this Textblock. <StackPanel Grid.Column="0" Margin="0 0 0 10"> <TextBlock FontWeight="DemiBold" Text="Account closure" x:Name="Message" Margin="0 6 0 2" FontSize="18" /> <StackPanel Orientation="Horizontal" > <TextBlock Text="A random text here, here, here " Margin="0 6 0 0" FontSize="18" /> <TextBlock Text="AZEQSD" Margin="0 6 0 0" TextWrapping="Wrap" FontWeight="DemiBold" FontSize="18" /> </StackPanel> </StackPanel> The output (The select...

Textbox not updating when static object method to update property is called

Image
Clash Royale CLAN TAG #URR8PPP Textbox not updating when static object method to update property is called First, let me state I am new to C# altogether. At the moment I am working on a program, and have been trying to get something that I thought would be rather simple to do. This is apparently not the case. I'll show here a very small example of what I have been trying to do. This is functionally identical, but without all the extra things that I have in the real project. We have 3 files here. MainWindow.xaml <Window.Resources> <CollectionViewSource x:Key="data1ViewSource" d:DesignSource="{d:DesignInstance {x:Type local:Data1}, CreateList=True}"/> </Window.Resources> <Grid> <Button x:Name="TestButton" Content="Button" HorizontalAlignment="Left" Margin="78,25,0,0" VerticalAlignment="Top" Width="75" Click="TestButton_Click"/> <TextBox x:Name="t...

Find the ScrollViewer which contains a Canvas froom within the Canvas instance

Image
Clash Royale CLAN TAG #URR8PPP Find the ScrollViewer which contains a Canvas froom within the Canvas instance I have a class which extends Canvas in WPF. Canvas This class is placed in a ScrollViewer . ScrollViewer Without passing a specific reference to the ScrollViewer into the Canvas , I want to find the ScrollViewer which contains the Canvas from within the Canvas itself. ScrollViewer Canvas ScrollViewer Canvas Canvas The Parent property of the class which extends Canvas is null , and every attempt to use the VisualTreeHelper just returns null as well. Parent Canvas null VisualTreeHelper null Is this possible to achieve? Example Code: cs - public class ExtendedCanvas:Canvas { //I wish to automatically populate this scroll viewer //reference to the instance of the scrollviwer which contains //this ExtendedCanvas instance private ScrollViewer _containingScrollViewer = null; } xaml - <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalS...

Run method missing in xaml class

Image
Clash Royale CLAN TAG #URR8PPP Run method missing in xaml class I am using F# and XAML in order to create a GUI but unfortunately after creating the type for the xaml I don't have a run method available. What am I missing here? code : module Program open FsXaml open System type App = XAML<"App.xaml"> [<STAThread>] [<EntryPoint>] let main argv = let app = App() app.Run() By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Cannot resolve symbol in CellTemplate binding

Image
Clash Royale CLAN TAG #URR8PPP Cannot resolve symbol in CellTemplate binding I have a ListView control ItemsSource bound to Producers property and it works well. But when I try to add some DataTriggers I am getting Cannot resolve symbol VS warning. Code works but I want to get rid of warning by explicitly specifying binding source. Producers Cannot resolve symbol I tried to use RelativeSource but found that CellTemplate can not use relative source as it is not part of VisualTree. <ListView ItemsSource="{Binding Producers, ElementName=This}"> <ListView.View> <GridView> <GridViewColumn Header="Id" DisplayMemberBinding="{Binding Id}"></GridViewColumn> <GridViewColumn Header="Description" DisplayMemberBinding="{Binding Description}"></GridViewColumn> <GridViewColumn Header="Up"> <GridViewColumn.CellTemplate> ...

Bind selected DataGrid row to textbox

Image
Clash Royale CLAN TAG #URR8PPP Bind selected DataGrid row to textbox I want to bind a textbox to a selected DataGrid . I have already binded the list to a datagrid but now I would like to bind the TextBox text to the DataGrid selected row so its content will be placed into the TextBox DataGrid TextBox DataGrid TextBox txtOccArea.DataContext = hegData; //hegData is a list of an object Thanks! What have you tried so far?? Please post some code – Ipsit Gaur 11 hours ago Just updated my post – Hancs 10 hours ago You should actually consider binding selected value of List to the value of TextBox – Ipsit Gaur 10 hours ago ...