Binding DataGrid in WPF [duplicate] - c#

I am doing a simple DataBinding application in WPF. In this app whatever I type in a TextBox named txtName, should appear in the Label. For this purpose I used binding in WPF, but its not getting bound.
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="315*" />
<ColumnDefinition Width="188*" />
</Grid.ColumnDefinitions>
<TextBox Height="23" HorizontalAlignment="Left"
Margin="79,12,0,0" Name="txtName"
VerticalAlignment="Top" Width="120" />
<Label Height="28" HorizontalAlignment="Left"
Margin="22,12,0,0" Name="label1"
VerticalAlignment="Top" Width="42"
Content="Name"/>
<TextBox Height="23" HorizontalAlignment="Left"
Margin="79,56,0,0" Name="txtSirName"
VerticalAlignment="Top" Width="120" />
<Label Content="SirName" Height="28"
HorizontalAlignment="Left" Margin="12,56,0,0"
Name="label2" VerticalAlignment="Top" Width="52" />
<!-- Following is the label which I bound -->
<Label Content="{Binding ElementName=txtName,Path=text}"
Height="28" HorizontalAlignment="Left" Margin="47,112,0,0"
Name="label3" VerticalAlignment="Top" Width="171" />
</Grid>
I am new to WPF. Please guide me.

Pretty sure XAML is case sensitive. Your binding path is text when it should be Text.

Path=*T*ext
It's a typo problem.

TextBox has property Text, not text. Small mistake :)
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="315*" />
<ColumnDefinition Width="188*" />
</Grid.ColumnDefinitions>
<TextBox Height="23" HorizontalAlignment="Left" Margin="79,12,0,0" Name="txtName" VerticalAlignment="Top" Width="120" />
<Label Height="28" HorizontalAlignment="Left" Margin="22,12,0,0" Name="label1" VerticalAlignment="Top" Width="42" Content="Name"/>
<TextBox Height="23" HorizontalAlignment="Left" Margin="79,56,0,0" Name="txtSirName" VerticalAlignment="Top" Width="120" />
<Label Content="SirName" Height="28" HorizontalAlignment="Left" Margin="12,56,0,0" Name="label2" VerticalAlignment="Top" Width="52" />
<Label Content="{Binding ElementName=txtName,Path=Text}" Height="28" HorizontalAlignment="Left" Margin="47,112,0,0" Name="label3" VerticalAlignment="Top" Width="171" />
</Grid>

Try this
<Label Content="{Binding Source={x:Reference txtName}, Path=text}" Height="28" HorizontalAlignment="Left" Margin="47,112,0,0" Name="label3" VerticalAlignment="Top" Width="171" />

Related

Impossible to create scrollbar C# WPF

I am currently trying to put a scrollBar in my C# app (using WPF)
even if I use a scrollbar object in WPF
(the scrollbar is still disable (in grey))
<GroupBox Header="Setting" Margin="5,0,5,0" Grid.Row="1">
<ScrollViewer HorizontalScrollBarVisibility="Auto" IsManipulationEnabled="True">
<TabControl x:Name="tabSetting" Margin="5,0,5,0" >
<TabItem x:Name="Tab_CmdSettings" Header="CMD settings">
<Grid Name="grid_CMD_settings" ScrollViewer.CanContentScroll="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="8*"/>
<ColumnDefinition Width="10*"/>
</Grid.ColumnDefinitions>
<Label Content="A1A2 fall voltage (% Un_min)" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<TextBox x:Name="textBox_buff_dtr" Height="21" TextWrapping="Wrap" Text="nvm_dtr" HorizontalAlignment="Left" Margin="0,3,0,0" VerticalAlignment="Top" Width="120" Grid.Column="1" />
<Label x:Name="label_Unmin" Content="Un_min= " HorizontalAlignment="Left" Margin="130,0,0,0" VerticalAlignment="Top" Grid.Column="1"/>
<Label Content="A1A2 rise voltage (% Un_max)" HorizontalAlignment="Left" Margin="0,20,0,0" VerticalAlignment="Top" Grid.Column="0"/>
...
...
OR
I try to use the Property
AutoScroll = "true"
in my form.
But it was not recognized and it crash during compile
I think that this Properties come from the WinForm not WPF
<GroupBox Header="Protection Parameters" Grid.Row="0" Grid.ColumnSpan="2" AutoScroll="True">
<Grid Name="grid_Protection" AutoScroll="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="84*"/>
<ColumnDefinition Width="145*"/>
<ColumnDefinition Width="287*"/>
</Grid.ColumnDefinitions>
<Label Content="Short circuit function selection" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Grid.Column="0" Grid.ColumnSpan="2"/>
<RadioButton x:Name="radioButton_buff_enascc_On" GroupName="group_enascc" Content="Enable" HorizontalAlignment="Left" Margin="0,5,0,0" VerticalAlignment="Top" Grid.Column="2" IsChecked="True"/>
<RadioButton x:Name="radioButton_buff_enascc_Off" GroupName="group_enascc" Content="Disable" HorizontalAlignment="Left" Margin="100,5,0,0" VerticalAlignment="Top" Grid.Column="2" />
<Label Content="Short circuit current level (x Ir_max)" HorizontalAlignment="Left" Margin="0,20,0,0" VerticalAlignment="Top" Grid.Column="0" Grid.ColumnSpan="2"/>
<TextBox x:Name="textBox_buff_ie3scc" Height="21" TextWrapping="Wrap" Text="nvm_ie3scc" HorizontalAlignment="Left" Margin="0,23,0,0" VerticalAlignment="Top" Width="120" Grid.Column="2" />
</GroupBox>
...
</Grid>
...
</TabItem>
...
Does anyone know what I am doing wrong?
Doesn't it enough to insert a scrollbar or add AutoSize?
Is it mandatory to code in C#?
From the Properties of WinForms make the AutoScroll Property True.
The ScrollBar will be only appeared
if the Content of the elements of the Form is bigger than the actual Form Control or
if the Form does not fit in the screen resolution of the screen.
Try adding more controls to make your window size less than the currently present content so that height current view is greater than the present components, so there will be a need for a scroll bar. hence your scroll bar is displayed accordingly.
#Brainy_Clown
Agree but ...i put all the graphical object in a StackPanel to set the min size.
when i reduce the windows to min or max, the scrollbar still unavailable.
<Window x:Class="MPDE_Monitor.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MPDE_Monitor"
mc:Ignorable="d"
Title="MPDE Monitor" Height="980" Width="600" Closing="Window_Closing" ResizeMode="CanResizeWithGrip" MinWidth="600" MinHeight="700">
<Grid>
<Menu IsMainMenu="True" VerticalAlignment="Top">
<MenuItem Header="_File">
<MenuItem x:Name="menu_connect" Header="_Connect" Click="connect_Click" />
<MenuItem x:Name="menu_reloadini" Header="Reload INI file" Click="menu_reloadini_Click" />
<TextBox Text="Factory mode" KeyDown="TextBox_KeyDown" PreviewMouseLeftButtonDown="TextBox_PreviewMouseLeftButtonDown"/>
<Separator />
<MenuItem x:Name="menu_exit" Header="_Exit" Click="menu_exit_Click" />
</MenuItem>
<MenuItem x:Name="menu_about" Header="_About" Click="menu_about_Click" />
</Menu>
<GroupBox x:Name="group1" Header="Connection settings" Margin="9,22,10,0" VerticalAlignment="Top" Height="71">
<Grid Margin="2,0,-3,0">
<RadioButton x:Name="radioUART" GroupName="com_port" Content="UART" HorizontalAlignment="Left" Margin="50,8,0,0" VerticalAlignment="Top" IsChecked="True" Checked="RadioButton_Checked"/>
<RadioButton x:Name="radioSPI" GroupName="com_port" Content="SPI" HorizontalAlignment="Left" Margin="7,8,0,0" VerticalAlignment="Top" Checked="RadioButton_Checked"/>
<Label Content="Port :" Margin="103,3,315,0" VerticalAlignment="Top"/>
<ComboBox x:Name="Comm_port" HorizontalAlignment="Left" Margin="139,4,0,0" VerticalAlignment="Top" Width="60" DropDownOpened="Comm_port_DropDownOpened"/>
<Button x:Name="connect" Content="Connect" HorizontalAlignment="Left" Margin="207,4,0,0" VerticalAlignment="Top" Width="70" Click="connect_Click"/>
<Label x:Name="conn_status" Content="connection msg" Margin="282,0,69,0" VerticalAlignment="Top" Height="29"/>
...
<Label Content="Factory mode:" Margin="7,23,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="91" RenderTransformOrigin="0.479,-0.25"/>
<TextBox x:Name="password" Text="Password" KeyDown="TextBox_KeyDown" PreviewMouseLeftButtonDown="TextBox_PreviewMouseLeftButtonDown" HorizontalAlignment="Left" Margin="102,28,0,0" VerticalAlignment="Top"></TextBox>
</Grid>
</GroupBox>
<TabControl x:Name="tabControl" Margin="10,98,10,227">
...
<TabItem x:Name="Tab_Conf_Setting" Header="Config and Settings">
<Grid Name="grid_Monitor1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<GroupBox Header="Product" Margin="5,0,5,0" Grid.Row="0">
<Grid Name="grid_Product" >
<Label Content="Target product" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Top"/>
<ComboBox x:Name="comboBox_buff_tag" HorizontalAlignment="Left" Margin="125,3,0,0" VerticalAlignment="Top" Width="120" SelectionChanged="ComboBox_SelectionChanged">
<ComboBoxItem Content="B0/B1 24V" IsSelected="True"/>
<ComboBoxItem Content="B0/B1 Wide range"/>
</ComboBox>
<Label Content="Ir range (A)" HorizontalAlignment="Left" Margin="10,30,0,0" VerticalAlignment="Top"/>
<ComboBox x:Name="comboBox_buff_range" HorizontalAlignment="Left" Margin="125,33,0,0" VerticalAlignment="Top" Width="120">
<ComboBoxItem Content="not_selected (default)" IsSelected="True"/>
<ComboBoxItem Content="[0.15A - 0.6A] (LUCxX6xx)"/>
...
</ComboBox>
<Label Content="A1A2 voltage (V)" HorizontalAlignment="Left" Margin="275,0,0,0" VerticalAlignment="Top"/>
<ComboBox x:Name="comboBox_buff_a1a2" HorizontalAlignment="Left" Margin="400,3,0,0" VerticalAlignment="Top" Width="120" SelectionChanged="ComboBox_SelectionChanged">
<ComboBoxItem Content="not_selected (default)" IsSelected="True"/>
<ComboBoxItem Content="24Vdc (LUxxxxBL)"/>
...
</ComboBox>
<Label Content="Type of control unit" HorizontalAlignment="Left" Margin="275,30,0,0" VerticalAlignment="Top"/>
<ComboBox x:Name="comboBox_buff_uctype" HorizontalAlignment="Left" Margin="400,33,0,0" VerticalAlignment="Top" Width="120">
<ComboBoxItem Content="not_selected (default)" IsSelected="True"/>
<ComboBoxItem Content="B0 - Class 10 - 3 phases [LUCA]"/>
...
</ComboBox>
<Label Content="Diagnostic contactor (only B3)" HorizontalAlignment="Left" Margin="10,55,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<RadioButton x:Name="radioButton_buff_diag_On" GroupName="group_diag" Content="Enable" HorizontalAlignment="Left" Margin="185,62,0,0" VerticalAlignment="Top" IsChecked="True"/>
<RadioButton x:Name="radioButton_buff_diag_Off" GroupName="group_diag" Content="Disable" HorizontalAlignment="Left" Margin="300,62,0,0" VerticalAlignment="Top" />
</Grid>
</GroupBox>
<GroupBox Header="Setting" Margin="5,0,5,0" Grid.Row="1">
<ScrollViewer HorizontalScrollBarVisibility="Auto" IsManipulationEnabled="True">
<StackPanel MinHeight="700" MinWidth="500">
<TabControl x:Name="tabSetting" Margin="5,0,5,0">
<TabItem x:Name="Tab_CmdSettings" Header="CMD settings">
<Grid Name="grid_CMD_settings" ScrollViewer.CanContentScroll="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="8*"/>
<ColumnDefinition Width="10*"/>
</Grid.ColumnDefinitions>
<Label Content="A1A2 fall voltage (% Un_min)" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<TextBox x:Name="textBox_buff_dtr" Height="21" TextWrapping="Wrap" Text="nvm_dtr" HorizontalAlignment="Left" Margin="0,3,0,0" VerticalAlignment="Top" Width="120" Grid.Column="1" />
...
</Grid>
</TabItem>
<TabItem x:Name="Tab_PTR_Settings" Header="PRT settings" ScrollViewer.CanContentScroll="True">
<Grid Name="grid_PTR_Settings" ScrollViewer.CanContentScroll="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30*"/>
<ColumnDefinition Width="481*"/>
</Grid.ColumnDefinitions>
<GroupBox Header="Protection Parameters" Grid.Row="0" Grid.ColumnSpan="2">
<Grid Name="grid_Protection">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="8*"/>
<ColumnDefinition Width="10*"/>
</Grid.ColumnDefinitions>
<Label Content="Short circuit function selection" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<RadioButton x:Name="radioButton_buff_enascc_On" GroupName="group_enascc" Content="Enable" HorizontalAlignment="Left" Margin="0,5,0,0" VerticalAlignment="Top" Grid.Column="1" IsChecked="True"/>
<RadioButton x:Name="radioButton_buff_enascc_Off" GroupName="group_enascc" Content="Disable" HorizontalAlignment="Left" Margin="100,5,0,0" VerticalAlignment="Top" Grid.Column="1" />
<Label Content="Short circuit current level (x Ir_max)" HorizontalAlignment="Left" Margin="0,20,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<TextBox x:Name="textBox_buff_ie3scc" Height="21" TextWrapping="Wrap" Text="nvm_ie3scc" HorizontalAlignment="Left" Margin="0,23,0,0" VerticalAlignment="Top" Width="120" Grid.Column="1" />
<Label Content="Magnetic function selection" HorizontalAlignment="Left" Margin="0,40,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<RadioButton x:Name="radioButton_buff_enamgn_On" GroupName="group_enamgn" Content="Enable" HorizontalAlignment="Left" Margin="0,45,0,0" VerticalAlignment="Top" Grid.Column="1" IsChecked="True"/>
<RadioButton x:Name="radioButton_buff_enamgn_Off" GroupName="group_enamgn" Content="Disable" HorizontalAlignment="Left" Margin="100,45,0,0" VerticalAlignment="Top" Grid.Column="1"/>
<Label Content="Magnetic current level (x Ir)" HorizontalAlignment="Left" Margin="0,60,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<TextBox x:Name="textBox_buff_imgn" Height="21" TextWrapping="Wrap" Text="nvm_imgn" HorizontalAlignment="Left" Margin="0,63,0,0" VerticalAlignment="Top" Width="120" Grid.Column="1"/>
<Label Content="TRIP when magnetic fault (only B3)" HorizontalAlignment="Left" Margin="0,80,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<RadioButton x:Name="radioButton_buff_trpmgn_On" GroupName="group_trpmgn" Content="Enable" HorizontalAlignment="Left" Margin="0,85,0,0" VerticalAlignment="Top" Grid.Column="1" IsChecked="True"/>
<RadioButton x:Name="radioButton_buff_trpmgn_Off" GroupName="group_trpmgn" Content="Disable" HorizontalAlignment="Left" Margin="100,85,0,0" VerticalAlignment="Top" Grid.Column="1"/>
<Label Content="Overload function selection" HorizontalAlignment="Left" Margin="0,100,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<RadioButton x:Name="radioButton_buff_enaovl_On" GroupName="group_enaovl" Content="Enable" HorizontalAlignment="Left" Margin="0,105,0,0" VerticalAlignment="Top" Grid.Column="1" IsChecked="True"/>
<RadioButton x:Name="radioButton_buff_enaovl_Off" GroupName="group_enaovl" Content="Disable" HorizontalAlignment="Left" Margin="100,105,0,0" VerticalAlignment="Top" Grid.Column="1"/>
<Label Content="Protection class" HorizontalAlignment="Left" Margin="0,120,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<ComboBox x:Name="comboBox_buff_cls" HorizontalAlignment="Left" Margin="0,123,0,0" VerticalAlignment="Top" Width="120" Grid.Column="1">
<ComboBoxItem Content="Class 5" IsSelected="True" />
<ComboBoxItem Content="Class 10"/>
</ComboBox>
<Label Content="Motor type" HorizontalAlignment="Left" Margin="0,140,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<RadioButton x:Name="radioButton_buff_mono_On" GroupName="group_mono" Content="Single phase" HorizontalAlignment="Left" Margin="0,145,0,0" VerticalAlignment="Top" Grid.Column="1" IsChecked="True"/>
<RadioButton x:Name="radioButton_buff_mono_Off" GroupName="group_mono" Content="Three phase" HorizontalAlignment="Left" Margin="100,145,0,0" VerticalAlignment="Top" Grid.Column="1"/>
<Label Content="Phase loss function selection" HorizontalAlignment="Left" Margin="0,160,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<RadioButton x:Name="radioButton_buff_enaloss_On" GroupName="group_enaloss" Content="Enable" HorizontalAlignment="Left" Margin="0,165,0,0" VerticalAlignment="Top" Grid.Column="1" IsChecked="True"/>
<RadioButton x:Name="radioButton_buff_enaloss_Off" GroupName="group_enaloss" Content="Disable" HorizontalAlignment="Left" Margin="100,165,0,0" VerticalAlignment="Top" Grid.Column="1"/>
<Label Content="Phase loss duration (ms)" HorizontalAlignment="Left" Margin="0,180,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<TextBox x:Name="textBox_buff_tloss" Height="21" TextWrapping="Wrap" Text="nvm_tloss" HorizontalAlignment="Left" Margin="0,183,0,0" VerticalAlignment="Top" Width="120" Grid.Column="1"/>
<Label Content="TRIP when phase loss fault (only B3)" HorizontalAlignment="Left" Margin="0,200,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<RadioButton x:Name="radioButton_buff_trploss_On" GroupName="group_trploss" Content="Enable" HorizontalAlignment="Left" Margin="0,205,0,0" VerticalAlignment="Top" Grid.Column="1" IsChecked="True"/>
<RadioButton x:Name="radioButton_buff_trploss_Off" GroupName="group_trploss" Content="Disable" HorizontalAlignment="Left" Margin="100,205,0,0" VerticalAlignment="Top" Grid.Column="1"/>
<Label Content="Ground fault function selection" HorizontalAlignment="Left" Margin="0,220,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<RadioButton x:Name="radioButton_buff_enagf_On" GroupName="group_enagf" Content="Enable" HorizontalAlignment="Left" Margin="0,225,0,0" VerticalAlignment="Top" Grid.Column="1" IsChecked="True"/>
<RadioButton x:Name="radioButton_buff_enagf_Off" GroupName="group_enagf" Content="Disable" HorizontalAlignment="Left" Margin="100,225,0,0" VerticalAlignment="Top" Grid.Column="1"/>
<Label Content="Ground fault level (x Ir)" HorizontalAlignment="Left" Margin="0,240,0,0" VerticalAlignment="Top" Grid.Column="0" />
<TextBox x:Name="textBox_buff_ig2" Height="21" TextWrapping="Wrap" Text="nvm_ig2" HorizontalAlignment="Left" Margin="0,245,0,0" VerticalAlignment="Top" Width="120" Grid.Column="1"/>
<Label Content="Desensitization level (x Ir)" HorizontalAlignment="Left" Margin="0,260,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<ComboBox x:Name="comboBox_buff_idsz1" HorizontalAlignment="Left" Margin="0,263,0,0" VerticalAlignment="Top" Width="120" Grid.Column="1">
<ComboBoxItem Content="18.0 (No desensitization !)" IsSelected="True"/>
<ComboBoxItem Content="3.0"/>
</ComboBox>
<Label Content="Desensitizated GF level (x Ir)" HorizontalAlignment="Left" Margin="0,280,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<ComboBox x:Name="comboBox_buff_igdsz1" HorizontalAlignment="Left" Margin="0,283,0,0" VerticalAlignment="Top" Width="120" Grid.Column="1">
<ComboBoxItem Content="2.0" IsSelected="True"/>
<ComboBoxItem Content="3.0"/>
</ComboBox>
<Label Content="TRIP when ground fault (only B3)" HorizontalAlignment="Left" Margin="0,300,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<RadioButton x:Name="radioButton_buff_trpgf_On" GroupName="group_trpgf" Content="Enable" HorizontalAlignment="Left" Margin="0,305,0,0" VerticalAlignment="Top" Grid.Column="1" IsChecked="True"/>
<RadioButton x:Name="radioButton_buff_trpgf_Off" GroupName="group_trpgf" Content="Disable" HorizontalAlignment="Left" Margin="100,305,0,0" VerticalAlignment="Top" Grid.Column="1"/>
</Grid>
</GroupBox>
<GroupBox Header="Calibration" Grid.Row="1" Grid.ColumnSpan="2">
<Grid Name="grid_Calibration">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="8*"/>
<ColumnDefinition Width="10*"/>
</Grid.ColumnDefinitions>
<Label Content="Calibration gain phase 1" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<TextBox x:Name="textBox_buff_cal1" Height="21" TextWrapping="Wrap" Text="nvm_cal1" HorizontalAlignment="Left" Margin="0,5,0,0" VerticalAlignment="Top" Width="120" Grid.Column="1" />
<Label Content="Calibration gain phase 2" HorizontalAlignment="Left" Margin="0,20,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<TextBox x:Name="textBox_buff_cal2" Height="21" TextWrapping="Wrap" Text="nvm_cal2" HorizontalAlignment="Left" Margin="0,25,0,0" VerticalAlignment="Top" Width="120" Grid.Column="1" />
<Label Content="Calibration gain phase 3" HorizontalAlignment="Left" Margin="0,40,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<TextBox x:Name="textBox_buff_cal3" Height="21" TextWrapping="Wrap" Text="nvm_cal3" HorizontalAlignment="Left" Margin="0,45,0,0" VerticalAlignment="Top" Width="120" Grid.Column="1" />
</Grid>
</GroupBox>
</Grid>
</TabItem>
<TabItem x:Name="Tab_Safety_and_others_Settings" Header="Safety and Others settings">
<Grid Name="grid_Tab_and_safety">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="346*"/>
<ColumnDefinition Width="165*"/>
</Grid.ColumnDefinitions>
<GroupBox Header="Safety" Grid.Row="0" Grid.ColumnSpan="2">
<Grid Name="grid_Safety">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="8*"/>
<ColumnDefinition Width="10*"/>
</Grid.ColumnDefinitions>
<Label Content="ETH pin detection" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<RadioButton x:Name="radioButton_buff_eth_On" GroupName="group_eth" Content="Enable" HorizontalAlignment="Left" Margin="0,5,0,0" VerticalAlignment="Top" Grid.Column="1" IsChecked="True"/>
<RadioButton x:Name="radioButton_buff_eth_Off" GroupName="group_eth" Content="Disable" HorizontalAlignment="Left" Margin="100,5,0,0" VerticalAlignment="Top" Grid.Column="1"/>
...
...
</Grid>
</GroupBox>
<GroupBox Header="Wide range parameters" Grid.Row="1" Grid.ColumnSpan="2">
<Grid Name="grid_wild_range">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="8*"/>
<ColumnDefinition Width="10*"/>
</Grid.ColumnDefinitions>
<Label Content="Inrush proportional coeff." HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<TextBox x:Name="textBox_buff_kp_iap" Height="23" TextWrapping="Wrap" Text="nvm_kp_iap" HorizontalAlignment="Left" Margin="0,3,0,0" VerticalAlignment="Top" Width="120" Grid.Column="1" />
...
</Grid>
</GroupBox>
</Grid>
</TabItem>
<TabItem x:Name="Tab_Traceability" Header="Traceability">
<Grid Name="grid_Traceability" Grid.ColumnSpan="4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="8*"/>
<ColumnDefinition Width="10*"/>
</Grid.ColumnDefinitions>
<Label Content="Production year (> 2020)" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<TextBox x:Name="textBox_buff_year" Height="23" TextWrapping="Wrap" Text="nvm_year" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Width="120" Grid.Column="1" />
...
</Grid>
</TabItem>
</TabControl>
</StackPanel>
</ScrollViewer>
</GroupBox>
</Grid>
</TabItem>
<TabItem x:Name="TabMonitor" Header="Monitoring">
<TabControl x:Name="tabControlmonitoring2" Margin="5,0,5,0">
...
<TabItem x:Name="Tab_Fault" Header="Fault Status">
<Grid Name="grid_Fault">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="8*"/>
<ColumnDefinition Width="10*"/>
</Grid.ColumnDefinitions>
<Label Content="Short circuit fault" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Grid.Column="0"/>
<RadioButton x:Name="radioButton_fltscc_On" GroupName="group_fltscc" Content="Enable" HorizontalAlignment="Left" Margin="0,5,0,0" VerticalAlignment="Top" Grid.Column="1" IsChecked="True" IsEnabled="False"/>
<RadioButton x:Name="radioButton_fltscc_Off" GroupName="group_fltscc" Content="Disable" HorizontalAlignment="Left" Margin="100,5,0,0" VerticalAlignment="Top" Grid.Column="1" IsEnabled="False"/>
...
</Grid>
</TabItem>
...
<TabItem x:Name="Tab_Diag" Header="Diagnostic Status">
<Grid Name="grid_Diag">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="8*"/>
<ColumnDefinition Width="10*"/>
</Grid.ColumnDefinitions>
<Label Content="Initial IDIAG current (mA)" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Grid.Column="0" Grid.ColumnSpan="2"/>
<TextBox x:Name="textBox_adcmsr_idiag1" Height="23" TextWrapping="Wrap" Text="adcmsr_idiag1" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Width="120" Grid.Column="2" IsEnabled="False" />
...
...
</Grid>
</TabItem>
</TabControl>
</TabItem>
</TabControl>
<GroupBox x:Name="group2" Header="Storing and sending configuration" Margin="10,0,10,79" VerticalAlignment="Bottom" Height="148">
<Grid Margin="2,0,-3,1">
<RadioButton x:Name="radio_conf_current" GroupName="conf_read" Content="Current conf" HorizontalAlignment="Left" Margin="8,5,0,0" VerticalAlignment="Top" IsChecked="True" FontSize="11" FontStyle="Italic" Checked="radio_conf_current_Checked" IsEnabled="False" Grid.ColumnSpan="2"/>
<RadioButton x:Name="radio_conf_modif" GroupName="conf_read" Content="Modifying" HorizontalAlignment="Left" Margin="97,5,0,0" VerticalAlignment="Top" FontSize="11" FontStyle="Italic" Checked="radio_conf_current_Checked" IsEnabled="False"/>
<Label x:Name="label_title" Content="Configuration title" HorizontalAlignment="Left" Margin="181,0,0,0" VerticalAlignment="Top" Width="106" FontStyle="Italic"/>
<TextBox x:Name="textBox_title" HorizontalAlignment="Left" Height="23" Margin="295,2,0,0" TextWrapping="Wrap" Text="conf_title" VerticalAlignment="Top" Width="129" FontStyle="Italic" FontSize="11" MaxLines="1" MaxLength="1000"/>
<Label x:Name="label_title_Corrupted" Content="" HorizontalAlignment="Left" Margin="439,2,0,0" VerticalAlignment="Top" Width="106" FontStyle="Italic"/>
<Label Content="List of available configurations :" HorizontalAlignment="Left" Margin="10,23,0,0" VerticalAlignment="Top"/>
<ListBox x:Name="listBox_config" HorizontalAlignment="Left" Height="70" Margin="18,43,0,0" VerticalAlignment="Top" Width="420" SelectionChanged="listBox_config_SelectionChanged"/>
<Button x:Name="btn_send_settings" Content="Send selected" HorizontalAlignment="Left" Margin="443,93,0,0" VerticalAlignment="Top" Width="109" Click="btn_send_settings_Click" IsEnabled="False" HorizontalContentAlignment="Center"/>
</Grid>
</GroupBox>
<Grid Margin="10,0,10,5" VerticalAlignment="Bottom">
...
...
</Grid>
</Grid>
</Window>

How do I resize TextBox to fit the Window size when it Maximized/Minimized?

How can I resize my TextBoxe's/Label's to fit the window size when I maximize/minimize it? At this point textboxes just go to the center of the window. What I want that they resized to fit the grid columns and rows size. How can I do that? I tried to difine to what column and row textbox belongs, thougth, it will resize accordingly to ColumnDefinition, but that didn't change anything.
<DockPanel Margin="2,46,0,0" Name="dockPanel1" Width="Auto">
<TabControl Height="Auto" Name="tabControl1" Width="Auto" VerticalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" DockPanel.Dock="Top">
<TabItem Header="tabItem1" Name="tabItem1">
<Grid Name="grid1" HorizontalAlignment="Center" VerticalAlignment="Top" Height="523" Width="766">
<Grid.RowDefinitions>
<RowDefinition MinHeight="0" Height="43*" />
<RowDefinition Height="45*" />
<RowDefinition Height="435*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="0" Width="Auto" />
<ColumnDefinition Width="Auto" MinWidth="100" />
<ColumnDefinition Width="385*" />
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" Grid.Row="0" Height="27" Name="textBox1" VerticalAlignment="Top" Margin="0,4,0,0" HorizontalAlignment="Right" Width="141" FontSize="14" HorizontalContentAlignment="Stretch" />
<Label Content="Label" Height="9" HorizontalAlignment="Left" Margin="16,7,0,0" Name="label1" VerticalAlignment="Top" Width="35" />
<Label Content="Supplier" Height="27" Name="label2" VerticalAlignment="Top" FontSize="14" FontFamily="Tahoma" FontWeight="Bold" Margin="6,4,0,0" Width="133" IsEnabled="True" HorizontalAlignment="Left" Foreground="Black" Background="White" />
<TextBox FontSize="14" Height="27" HorizontalAlignment="Stretch" Margin="140,6,0,0" Name="textBox11" VerticalAlignment="Top" Width="141" Grid.Row="1" />
<Label Content="Supplier Bank" FontFamily="Tahoma" FontSize="14" FontWeight="Bold" Height="27" Margin="6,6,142,0" Name="label3" VerticalAlignment="Top" Width="133" Grid.Row="1" Background="White" />
<TextBox FontSize="14" Height="27" HorizontalAlignment="Stretch" Margin="140,7,0,0" Name="textBox12" VerticalAlignment="Top" Width="141" Grid.Row="2" />
<Label Content="Account Number" FontFamily="Tahoma" FontSize="14" FontWeight="Bold" Height="27" Margin="6,7,142,0" Name="label4" VerticalAlignment="Top" Width="133" Grid.Row="2" Background="White" />
<TextBox FontSize="14" Height="27" Margin="134,4,110,0" Name="textBox2" VerticalAlignment="Top" Grid.Column="2" HorizontalAlignment="Stretch" Width="141" DataContext="{Binding ElementName=grid1, Path=ActualWidth}" />
<Label Content="Buyer" FontFamily="Tahoma" FontSize="14" FontWeight="Bold" Height="27" Margin="0,4,252,0" Name="label5" VerticalAlignment="Top" Width="133" Grid.Column="2" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Background="White" />
<TextBox FontSize="14" Grid.Row="1" Height="27" HorizontalAlignment="Left" Margin="134,6,0,0" Name="textBox3" VerticalAlignment="Top" Width="141" Grid.Column="2" />
<Label Content="Buyer Bank" FontFamily="Tahoma" FontSize="14" FontWeight="Bold" Grid.Row="1" Height="27" Margin="0,6,0,0" Name="label6" VerticalAlignment="Top" Width="133" Grid.Column="2" HorizontalAlignment="Left" Background="White" />
<TextBox FontSize="14" Grid.Row="2" Height="27" HorizontalAlignment="Left" Margin="134,7,0,0" Name="textBox4" VerticalAlignment="Top" Width="141" Grid.Column="2" />
<Label Content="Account Number" FontFamily="Tahoma" FontSize="14" FontWeight="Bold" Grid.Row="2" Height="27" Margin="0,7,0,0" Name="label7" VerticalAlignment="Top" Width="133" Grid.Column="2" HorizontalAlignment="Left" Background="White" />
</Grid>
</TabItem>
<TabControl.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0.035" />
<GradientStop Color="#FF1B327A" Offset="0.528" />
<GradientStop Color="#FF001E98" Offset="0.278" />
</LinearGradientBrush>
</TabControl.Background>
</TabControl>
</DockPanel>
Dont use a static value for the width attribute.
You can try "HorizontalAlignment=Stretch".

WPF TabIndex doesn't work correctly

I have a Problem with setting up the TabIndexes correctly. I have a Usercontrol with a GroupBox.
<GroupBox KeyboardNavigation.TabNavigation="Local" TabIndex="0">
<Grid KeyboardNavigation.TabNavigation="Continue">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0" KeyboardNavigation.TabNavigation="Continue">
<my:uscZeitraum TabIndex="1" />
<Label />
<ComboBox TabIndex="2" />
<Label />
<ComboBox TabIndex="3" HorizontalAlignment="Right" VerticalAlignment="Top" Width="88" />
<Label />
<ComboBox TabIndex="4" HorizontalAlignment="Right" VerticalAlignment="Top" Width="67" />
<Label />
<ComboBox TabIndex="5" IsEditable="True" GotFocus="cboVorgang_GotFocus" HorizontalAlignment="Right" VerticalAlignment="Top" Width="93" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="1" KeyboardNavigation.TabNavigation="Continue">
<Label />
<ComboBox TabIndex="6" HorizontalAlignment="Left" Width="192" Height="23" VerticalAlignment="Bottom" />
<Label />
<ComboBox TabIndex="7" Height="23" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="225" />
<Label />
<ComboBox IsEditable="True" TabIndex="8" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="67" />
<Label />
<ComboBox IsEditable="True" TabIndex="9" Width="80" />
</StackPanel>
</Grid>
</GroupBox>
The first Control is also a UserControl but this works like I want to. But if I reach the third ComboBox in the first StackPanel it just starts at the beginning again. It doesn't focus the fourth ComboBox and also doesn't jump into the second Row/Stackpanel. What could that be?
There must be some code in cboVorgang_GotFocus which is doing that. The code written there would be changing the tab order.

Scrollable grid

I have been struggling with making a grid scrollable in my wpf application and the scrollviewer is not working so I need something similar to overflow:scroll in CSS so if anybody could help I would be very grateful
<Grid Margin="12,49,0,54" Name="state_settings" Width="430" Visibility="Hidden" MaxHeight="200" Height="200" HorizontalAlignment="Left" VerticalAlignment="Top">
<ScrollViewer VerticalScrollBarVisibility="Auto" CanContentScroll="True">
<Grid Height="69" HorizontalAlignment="Left" Margin="13,10,0,0" Name="state_comp" VerticalAlignment="Top" Width="406">
<Label Content="Gesture" Height="28" HorizontalAlignment="Left" Margin="6,6,0,0" Name="label1" VerticalAlignment="Top" Width="103" FontWeight="Bold" />
<ComboBox Height="23" HorizontalAlignment="Left" Margin="6,31,0,0" Name="comboBox1" VerticalAlignment="Top" Width="103" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="167,31,0,0" Name="textBox1" VerticalAlignment="Top" Width="27" />
<Label Content="Min Duration" Height="28" HorizontalAlignment="Left" Margin="135,6,0,0" Name="label2" VerticalAlignment="Top" Width="89" FontWeight="Bold" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="258,31,0,0" Name="textBox2" VerticalAlignment="Top" Width="27" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="346,31,0,0" Name="textBox3" VerticalAlignment="Top" Width="36" />
<Label Content="Max Duration" Height="28" HorizontalAlignment="Left" Margin="230,6,0,0" Name="label3" VerticalAlignment="Top" Width="89" FontWeight="Bold" />
<Label Content="Transition" Height="28" HorizontalAlignment="Left" Margin="327,6,0,0" Name="label4" VerticalAlignment="Top" Width="71" FontWeight="Bold" />
</Grid>
</ScrollViewer>
</Grid>
I had to change a few things to make it easier to work with your code... for example, I had to remove the Visibility="Hidden", which was ridiculous of you to keep in your example. I also added a Background colour so that I could see the bounds of the Grid. I moved the ScrollViewer to be the outermost element and removed the unnecessary CanContentScroll property and some Height settings, but apart from that, you almost had it. Try this:
<ScrollViewer VerticalScrollBarVisibility="Auto">
<Grid Name="state_settings" Width="430" MaxHeight="200" Background="LightBlue" HorizontalAlignment="Left" VerticalAlignment="Top">
<Grid Height="69" HorizontalAlignment="Left" Margin="13,10,0,0" Name="state_comp" VerticalAlignment="Top" Width="406">
<Label Content="Gesture" Height="28" HorizontalAlignment="Left" Margin="6,6,0,0" Name="label1" VerticalAlignment="Top" Width="103" FontWeight="Bold" />
<ComboBox Height="23" HorizontalAlignment="Left" Margin="6,31,0,0" Name="comboBox1" VerticalAlignment="Top" Width="103" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="167,31,0,0" Name="textBox1" VerticalAlignment="Top" Width="27" />
<Label Content="Min Duration" Height="28" HorizontalAlignment="Left" Margin="135,6,0,0" Name="label2" VerticalAlignment="Top" Width="89" FontWeight="Bold" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="258,31,0,0" Name="textBox2" VerticalAlignment="Top" Width="27" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="346,31,0,0" Name="textBox3" VerticalAlignment="Top" Width="36" />
<Label Content="Max Duration" Height="28" HorizontalAlignment="Left" Margin="230,6,0,0" Name="label3" VerticalAlignment="Top" Width="89" FontWeight="Bold" />
<Label Content="Transition" Height="28" HorizontalAlignment="Left" Margin="327,6,0,0" Name="label4" VerticalAlignment="Top" Width="71" FontWeight="Bold" />
</Grid>
</Grid>
</ScrollViewer>
You may need to reduce the Height of your Window, or add more items in order to actually see the vertical ScrollBar, but if you do, you should now see that it scrolls.
Your UI with a ScrollBar:

XamlParseException on window initialization

I am getting this error when I go to open my WPF window and I have no idea what created the error or how to get rid of it. The error is highlighting and pointing to </Border> at the bottom.
'Initialization of 'Outlook_Add_In_Test.WPFExiEvent' threw an exception.' Line number '91' and line position '11'.
My WPF Code:
<Controls:MetroWindow x:Class="Outlook_Add_In_Test.WPFExiEvent"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:System="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d" d:DesignWidth="550" MaxHeight="640" MaxWidth="550" Title="Search for an Existing Event" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Height="340" HorizontalAlignment="Center" VerticalAlignment="Center">
<Controls:MetroWindow.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="Theme/Test.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
<ResourceDictionary Source="Theme/FlatButton.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Controls:MetroWindow.Resources>
<Border BorderBrush="Black" BorderThickness="1">
<Grid Margin="0,0,0,-1">
<Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="1" Margin="6,108,0,0" VerticalAlignment="Top" Width="524" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
<Border.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleY="-1"/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Border.RenderTransform>
</Border>
<Image x:Name="ImgDefactoLogo" HorizontalAlignment="Left" Height="36" Margin="10,10,0,0" VerticalAlignment="Top" Width="43" Source="Images/DeFactoERP.ico"/>
<Image x:Name="ImgAttachmentType" HorizontalAlignment="Left" Margin="65,10,0,0" Width="32" RenderTransformOrigin="0.143,0.778" Height="36" VerticalAlignment="Top"/>
<Label Content="Search for an Existing Event" HorizontalAlignment="Left" Height="36" Margin="97,19,0,0" VerticalAlignment="Top" Width="259" FontSize="16" FontFamily="Arial" FontWeight="Bold"/>
<TextBlock x:Name="LblInfo" HorizontalAlignment="Left" Height="47" Margin="10,60,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="524" FontSize="15" FontFamily="Arial" Text="Please search for an existing event in your De Facto ERP system that you want to use for adding the attachment to."/>
<Label Content="Event No:" HorizontalAlignment="Left" Height="43" Margin="7,126,0,0" VerticalAlignment="Top" Width="112" FontSize="16" FontFamily="Arial" FontWeight="Bold" Foreground="Black"/>
<Label Content="Event Subject:" HorizontalAlignment="Left" Height="43" Margin="7,164,0,0" VerticalAlignment="Top" Width="119" FontSize="16" FontFamily="Arial" FontWeight="Bold"/>
<TextBox x:Name="TxtEventNo" HorizontalAlignment="Left" Height="33" Margin="151,126,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="200" ToolTip="Enter Event Number..." KeyDown="TxtEventNo_KeyDown" TextChanged="TxtEventNo_TextChanged"/>
<TextBox x:Name="TxtSubject" HorizontalAlignment="Left" Height="33" Margin="151,164,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="200" KeyDown="TxtSubject_KeyDown" TextChanged="TxtSubject_TextChanged"/>
<Label Content="Event Customer:" HorizontalAlignment="Left" Height="43" Margin="7,202,0,0" VerticalAlignment="Top" Width="142" FontSize="16" FontFamily="Arial" FontWeight="Bold"/>
<TextBox x:Name="TxtCust" HorizontalAlignment="Left" Height="33" Margin="342,22,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="200" ToolTip="Enter Event Number..." TextChanged="TxtCust_TextChanged" KeyDown="TxtCust_KeyDown"/>
<CheckBox x:Name="ChkActive" Content="Active Events Only" IsChecked="True" HorizontalAlignment="Left" Height="19" Margin="13,238,0,0" VerticalAlignment="Top" Width="124" Checked="ChkActive_Checked" Unchecked="ChkActive_UnChecked"/>
<Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="1" Margin="7,267,0,0" VerticalAlignment="Top" Width="524" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
<Border.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleY="-1"/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Border.RenderTransform>
</Border>
<Button x:Name="BtnSearch" Click="BtnSearch_Click" HorizontalAlignment="Left" Width="100" Background="#FF333333" Foreground="White" FontWeight="Normal" FontSize="14" Margin="422,162,0,0" Height="37" VerticalAlignment="Top">
<TextBlock Text="SEARCH" VerticalAlignment="Center" TextAlignment="Right" FontSize="14" Width="73" Height="15" FontFamily="Arial" Foreground="White" RenderTransformOrigin="0.684,0.261"/>
</Button>
<ListBox x:Name="LstEvents" HorizontalAlignment="Left" Margin="10,300,0,14" Width="524" BorderBrush="Black" BorderThickness="2,2,1,1">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Height="97">
<Canvas x:Name="EventItem" HorizontalAlignment="Left" Height="97" VerticalAlignment="Top" Width="502" Background="{Binding LBackground}" Margin="0,0,0,-21">
<Label Content="Event:" HorizontalAlignment="Left" Height="33" VerticalAlignment="Top" Width="97" FontWeight="Bold" FontSize="14" Canvas.Left="1" Canvas.Top="2"/>
<Label Content="Subject:" HorizontalAlignment="Left" Height="33" VerticalAlignment="Top" Width="97" FontWeight="Bold" FontSize="14" Canvas.Left="1" Canvas.Top="23"/>
<Label Content="Body:" HorizontalAlignment="Left" Height="33" VerticalAlignment="Top" Width="97" FontWeight="Bold" FontSize="14" Canvas.Left="1" Canvas.Top="47"/>
<Button x:Name="BtnSelectEvent" Content="Select" HorizontalAlignment="Left" Height="34" VerticalAlignment="Top" Width="74" Background="#FF333333" Foreground="White" FontWeight="Normal" FontSize="14" Canvas.Left="418" Canvas.Top="33" Click="BtnSelectEvent_Click"/>
<Label Content="{Binding Lsubject}" Height="25" Canvas.Left="80" Canvas.Top="3" Width="333"/>
<Label Content="{Binding Lbody}" Height="25" Canvas.Left="80" Canvas.Top="25" Width="333"/>
<Label Content="{Binding Lbody}" Height="25" Canvas.Left="80" Canvas.Top="49" Width="333"/>
<Label Content="Customer:" HorizontalAlignment="Left" Height="33" VerticalAlignment="Top" Width="97" FontWeight="Bold" FontSize="14" Canvas.Left="1" Canvas.Top="69"/>
<Label Content="{Binding LCust}" Height="25" Canvas.Left="80" Canvas.Top="71" Width="333"/>
</Canvas>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Label x:Name="LblResultsReturned" Content="" HorizontalAlignment="Left" Height="27" Margin="37,273,0,-19" VerticalAlignment="Top" Width="492" FontWeight="Bold" FontFamily="Arial" FontSize="11" />
<Label x:Name="LblEventCount" Content="" HorizontalAlignment="Left" Height="27" Margin="10,273,0,-19" VerticalAlignment="Top" FontWeight="Bold" FontFamily="Arial" FontSize="11" />
<Image x:Name="ImgSearch" HorizontalAlignment="Left" Height="28" Margin="431,171,0,0" VerticalAlignment="Top" Width="22" Source="Images/Icon-Search-Big-White.png" RenderTransformOrigin="0.419,1.269"/>
<Label x:Name="LblError" Content="" HorizontalAlignment="Left" Height="27" Margin="199,273,0,-19" VerticalAlignment="Top" Width="330" FontWeight="Bold" FontFamily="Arial" FontSize="11" />
<Controls:ProgressRing x:Name="LoadingRing" IsActive="False" Margin="356,153,126,0" VerticalAlignment="Top"/>
</Grid>
</Border>
</Controls:MetroWindow>
Going on what you said in the comments it seems it is linked to the MahApps Metro Theme.
Take a look at this: https://github.com/MahApps/MahApps.Metro/issues/582
If you have referenced the Windows Interactivity dll try removing it.
In future remember to check the InnerException like SLaks said. You can learn a lot more from this and give you more to work on.
Maybe for someone it will be useful. Today I ran into the same problem:
"XamlParseException on window initialization" in project with nuget reference to MahApp.
I tryed reinstaling packages, removing references - nothithing helped.
In may case the problem was in app.config. When I removed these lines, problem disappeared:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Windows.Interactivity" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Does anyone know why this happens?
I think you just imported the wrong dll (NET40). Try to import the latest MahApps.Metro.dll (NET45).
It worked for me.
For me, I downgraded the MahApps.Metro to version 1.6.4 and the error has gone
I was using version 1.6.5 before
And the version of MahApps.Metro.Resources is 0.6.1

Categories

Resources