Anyone please help me to fix my problem. The error is:
The invocation of the constructor on type 'TestWs.MainWindow' that matches the specified binding constraints threw an exception.' Line number '6' and line position '9'.
Also showing:
Source information is missing from debug information for this module.
I viewed in disassembly window it shows like:
01112DE1 mov dword ptr [ebp-44h],eax
<Window x:Class="TestWs.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:TestWs"
mc:Ignorable="d"
Title="MainWindow" Height="467" Width="799" Background="#FF617EB0">
<Window.Resources>
<DataTemplate x:Key="DataTemplateItemDirect">
<StackPanel Orientation="Horizontal">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60" ></ColumnDefinition>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="60"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding userid}" Grid.Column="0" Width="50"/>
<TextBlock Text="{Binding Name}" Grid.Column="1" Width="150"/>
<Image Source="{Binding PictureString}" Grid.Column="2" Name="ImageName" Height="15" Width="15" />
</Grid>
</StackPanel>
</DataTemplate>
</Window.Resources>
<Grid>
<DockPanel LastChildFill="True" >
<StackPanel Orientation="Horizontal" Height="40" Width="700" DockPanel.Dock="Top">
<Label Name="lbAddress" Height="30" Width="60" Content="Address:" Margin="10,0,0,0"></Label>
<TextBox Name="txtAddr" Width="350" Height="20" Text="ws://localhost:52804/WSHandler.ashx"></TextBox>
<Button Name="btConnect" Height="20" Width="80" Content="Connect" Margin="10,0,0,0" Click="btConnect_Click"></Button>
<Button Name="btDisconnect" Height="20" Width="80" Content="Disconnect" Margin="10,0,0,0" Click="btDisconnect_Click"></Button>
<!-- <Button Name="btLogin" Width="80" Height="20" Content="Logout" Margin="10,10,0,0" Click="btLogin_Click" VerticalAlignment="Top"></Button> -->
</StackPanel>
<StackPanel Orientation="Vertical" VerticalAlignment="Top" DockPanel.Dock="Left">
<Label Name="lbUser" Height="auto" Width="auto" Margin="5" Foreground="Black" FontWeight="Bold" FontFamily="Cambria"/>
<Button x:Name="btnChat" Width="100" Height="30" Content="Chat" Click="btnChat_Click" />
<Button x:Name="btnFileTransfer" Width="100" Height="30" Content="File Transfer" Click="btnFileTransfer_Click" />
<Button x:Name="button3" Width="100" Height="30" Content="Notification" Click="button3_Click"/>
<Button x:Name="button5" Width="100" Height="30" Content="Group Create" Click="button5_Click"/>
<Button x:Name="button6" Width="100" Height="30" Content="GPS Msg" Click="button6_Click"/>
<Button x:Name="button4" Width="100" Height="30" Content="Remove User" Click="button4_Click"/>
<!-- <Button x:Name="button7" Width="100" Height="30" Content="button" Click="button7_Click"/> -->
<!-- <Button x:Name="button8" Width="100" Height="30" Content="UserList" Click="button8_Click"/> -->
</StackPanel>
<DockPanel DockPanel.Dock="Right" Width="270" >
<StackPanel>
<Label x:Name="label" Content="Group" Height="30" DockPanel.Dock="Top" />
<!-- <ListBox x:Name="listBox" Height="100" Margin="5" DockPanel.Dock="Top" /> -->
<!-- <DataGrid x:Name="grdGroup" Width="250" Height="120" VerticalAlignment="Top" Margin="5" AutoGenerateColumns="False" SelectionChanged="grdGroup_SelectionChanged_1" IsReadOnly="True" SelectedValuePath ="GroupId" >
<DataGrid.Columns>
<DataGridTextColumn Header="Group ID" Binding="{Binding GroupId}"/>
<DataGridTextColumn Header="Group Name" Binding="{Binding GroupName}"/>
<DataGridTextColumn Header="ParentId" Binding="{Binding ParentId}"/>
<DataGridTextColumn Header="Group" Binding="{Binding subgrp}"/>
</DataGrid.Columns>
</DataGrid> -->
<ListBox Name="lbGroupList" Width="auto" Height="130" Margin="5" DockPanel.Dock="Right" SelectionChanged="lbGroupList_SelectionChanged" SelectedValuePath ="GroupId" >
<ListBox.Template>
<ControlTemplate>
<ScrollViewer>
<DockPanel LastChildFill="True" Background="White">
<Grid DockPanel.Dock="Top" Background="CadetBlue" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60" ></ColumnDefinition>
<ColumnDefinition Width="90"></ColumnDefinition>
<ColumnDefinition Width="90"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Content="Group Id"></Label>
<Label Grid.Column="1" Content="Group Name"></Label>
<Label Grid.Column="2" Content="Group"></Label>
</Grid>
<ItemsPresenter></ItemsPresenter>
</DockPanel>
</ScrollViewer>
</ControlTemplate>
</ListBox.Template>
<ListBox.ItemTemplate>
<DataTemplate >
<StackPanel Orientation="Horizontal" >
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60" ></ColumnDefinition>
<ColumnDefinition Width="90"></ColumnDefinition>
<ColumnDefinition Width="90"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding GroupId}" Grid.Column="0" VerticalAlignment="Center" ></TextBlock>
<TextBlock Text="{Binding GroupName}" Grid.Column="1" VerticalAlignment="Center" ></TextBlock>
<TextBlock Text="{Binding subgrp}" Grid.Column="2" VerticalAlignment="Center"/>
</Grid>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Label x:Name="lblUser" Content="User" Height="30" DockPanel.Dock="Top" />
<ListBox x:Name="LstUserList" Height="130" Margin="5,0,5,0" DockPanel.Dock="Right" ItemTemplate="{DynamicResource DataTemplateItemDirect}" SelectionChanged="LstUserList_SelectionChanged_1" ItemsSource="{Binding UserDisplay}" IsSynchronizedWithCurrentItem="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" >
<ListBox.Template>
<ControlTemplate>
<ScrollViewer>
<DockPanel LastChildFill="True" Background="White">
<Grid DockPanel.Dock="Top" Background="CadetBlue" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60" ></ColumnDefinition>
<ColumnDefinition Width="130"></ColumnDefinition>
<ColumnDefinition Width="60"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Content="User Id"></Label>
<Label Grid.Column="1" Content="User Name"></Label>
<Label Grid.Column="2" Content="Status"></Label>
</Grid>
<ItemsPresenter></ItemsPresenter>
</DockPanel>
</ScrollViewer>
</ControlTemplate>
</ListBox.Template>
</ListBox>
<!-- <TextBox Name="txtRecivemessage" Margin="0,0,5,0" VerticalScrollBarVisibility="Auto" TextWrapping="Wrap" IsReadOnly="True" /> -->
<!-- <ListBox x:Name="lstUser" Margin="5"/> -->
<!--
<DataGrid x:Name="grdUsers" Height="121" Margin="5" SelectionChanged="grdUsers_SelectionChanged_1" AutoGenerateColumns="False" IsReadOnly="True">
<DataGrid.Columns>
<DataGridTextColumn Header="User ID" Binding="{Binding UserId}"/>
<DataGridTextColumn Header="User Name" Binding="{Binding UserName}"/>
<DataGridTextColumn Header="Status" Binding="{Binding StatusName}"/>
<DataGridTemplateColumn Header="delete">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Command="Delete" Content="Remove" Click="Button_Click_3"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid> -->
</StackPanel>
</DockPanel>
<StackPanel x:Name="stkUsrContainer" HorizontalAlignment="Center" >
<!-- <local:UctrlLogIn Width="400" Height="215" Loaded="UctrlLogIn_Loaded" /> -->
</StackPanel>
</DockPanel>
</Grid>
</Window>
This may be a duplicate of Here
They added this to app.config
<configuration> <startup useLegacyV2RuntimeActivationPolicy="true" /> </configuration>
Related
I have a following problem in my UWP project:
The data binding in DataGridTemplateColumn to another DataContext than for the row, doesn't work.
Here is my XAML structure:
<Page
x:Name="Page1"
x:Class="Project1.Class1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Project1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:controls="using:Microsoft.UI.Xaml.Controls"
xmlns:tools="using:Microsoft.Toolkit.Uwp.UI.Controls" xmlns:Interactivity="using:Microsoft.Xaml.Interactivity" xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<HyperlinkButton Content="<- Powrót" HorizontalAlignment="Left" FontSize="36" Foreground="#FF615E5A" VerticalAlignment="Top" Click="BackToMainPage" />
<TextBlock x:Name="pageTitle" Text="Title" HorizontalAlignment="Center" FontSize="36" />
<Grid Grid.Row="1" x:Name="body">
<Grid.RowDefinitions>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="Path:" />
<TextBox x:Name="path" Grid.Column="1" Text="{x:Bind Folder.Path}" />
<Button Grid.Column="2" Content="Choose folder" Click="SelectFolder" />
<TextBlock Grid.Row="1" Text="Name:" />
<TextBox x:Name="file" Grid.Row="1" Grid.Column="1" Text="{x:Bind FileName}" />
<TextBlock Grid.Row="1" Grid.Column="2" Text="X:"></TextBlock>
<ComboBox Grid.Row="1" Grid.Column="3" x:Name="scope">
<ComboBoxItem IsSelected="True" Content="M" Tag="M"/>
<ComboBoxItem Content="L" Tag="L"/>
<ComboBoxItem Content="K" Tag="K" />
</ComboBox>
<TextBlock Grid.Row="2" Text="Code:"></TextBlock>
<TextBox x:Name="code" Grid.Row="2" Grid.Column="1" Text="" />
<TextBlock Grid.Row="2" Grid.Column="2" Text="Name:"></TextBlock>
<TextBox x:Name="name" Grid.Row="2" Grid.Column="3" Text="" TextWrapping="Wrap"/>
<ListView Grid.Row="3"
Grid.ColumnSpan="4"
x:Name="list"
SelectedItem="{x:Bind SelectedSubmatrix, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{x:Bind SubmatrixList, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsStackPanel Orientation="Vertical"
HorizontalAlignment="Stretch"
ScrollViewer.HorizontalScrollMode="Disabled"
ScrollViewer.VerticalScrollMode="Auto" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Grid Width="{Binding ElementName=body, Path=ActualWidth}">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel>
<TextBlock Text="Name:"></TextBlock>
<TextBox Text="{Binding Name, Mode=TwoWay}" TextWrapping="Wrap"/>
</StackPanel>
<StackPanel Grid.Column="1">
<TextBlock Text="Type:"></TextBlock>
<ComboBox x:Name="type" SelectedValue="{Binding Type, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" SelectedValuePath="Tag">
<ComboBoxItem IsSelected="True" Content="L" Tag="L"/>
<ComboBoxItem Content="M" Tag="M"/>
</ComboBox>
</StackPanel>
<StackPanel x:Name="key" Grid.Column="2" Visibility="Collapsed">
<Interactivity:Interaction.Behaviors>
<Core:DataTriggerBehavior Binding="{Binding ElementName=type, Path=SelectedItem.Content}" Value="M">
<Core:ChangePropertyAction TargetObject="{Binding ElementName=key}" PropertyName="Visibility" Value="Visible" />
</Core:DataTriggerBehavior>
<Core:DataTriggerBehavior Binding="{Binding ElementName=type, Path=SelectedItem.Content}" Value="L">
<Core:ChangePropertyAction TargetObject="{Binding ElementName=key}" PropertyName="Visibility" Value="Collapsed" />
</Core:DataTriggerBehavior>
</Interactivity:Interaction.Behaviors>
<TextBlock Text="Key M:" />
<ComboBox SelectedItem="{Binding Key, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" SelectedValuePath="Tag">
<ComboBoxItem IsSelected="True" Content="1" Tag="1"/>
<ComboBoxItem Content="2" Tag="2"/>
<ComboBoxItem Content="3" Tag="3"/>
</ComboBox>
</StackPanel>
<Button Grid.Row="1" Content="Add" Command="{Binding Path=AddColumnCommand}" />
<tools:DataGrid Grid.Row="1"
Grid.Column="1"
Grid.ColumnSpan="4"
AutoGenerateColumns="False"
ItemsSource="{Binding Columns, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" RowHeight="200">
<tools:DataGrid.Columns>
<tools:DataGridTemplateColumn Header="Type">
<tools:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<!--<TextBlock Text="{Binding Name}" />-->
<TextBlock Text="{Binding ElementName=Page1, Path=DataContext.FileName}" />
</DataTemplate>
</tools:DataGridTemplateColumn.CellTemplate>
</tools:DataGridTemplateColumn>
<tools:DataGridTextColumn Header="Nazwa" Binding="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<!--<tools:DataGridTextColumn Header="Nazwa2" Binding="{Binding ElementName=Strona, Path=DataContext.FileName}" />-->
</tools:DataGrid.Columns>
</tools:DataGrid>
<!--<ComboBox ItemsSource="{Binding ElementName=Strona, Path=DataContext.Dictionary2}" />-->
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Button Grid.Row="4" HorizontalAlignment="Right" Content="Add main" Click="AddSubmatrix"/>
<Button Grid.Row="4" Grid.Column="1" HorizontalAlignment="Right" Content="Delete main" Click="DeleteSelectedSubmatrix"/>
<Button Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="2" HorizontalAlignment="Right" Content="Generate" Click="GenerateTemplate"/>
</Grid>
</Grid>
</Page>
Those three commented out lines were just for my testing and in all of them binding works properly, but for this uncommented one in DataGridTemplateColumn.CellTemplate -> DataTemplate doesn't. Does anybody knows why? And how to deal with it?
It's known issue for DataGrid, you can only access current item model's property within CellTemplate. It will not work, if access root datacontext by elementname markup. For this scenario we suggest your add FileName into each item like this case replay.
And the other way is intercepting DataGridTemplateColumn generate element method, and use new value to replace the old one.
For example, replace the Name property as the string "FileName"
public class CustomDataGridTemplateColumn : DataGridTemplateColumn
{
public CustomDataGridTemplateColumn()
{
}
protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
{
(dataItem as Item).Name = "FileName";
return base.GenerateElement(cell, dataItem);
}
public class Person
{
public string Name { get; set; }
public bool IsMan { get; set; }
}
}
Xaml Code
<controls:DataGrid.Columns>
<controls:DataGridTextColumn
Binding="{Binding Name}"
Header="Rank"
Tag="Rank"
/>
<controls:DataGridComboBoxColumn
Binding="{Binding Complete}"
Header="Mountain"
Tag="Mountain"
/>
<local:CustomDataGridTemplateColumn Header="Check" Tag="Test1">
<local:CustomDataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}"/>
<ToggleSwitch IsOn="{Binding Complete}" Visibility="Collapsed"/>
</StackPanel>
</DataTemplate>
</local:CustomDataGridTemplateColumn.CellTemplate>
</local:CustomDataGridTemplateColumn>
</controls:DataGrid.Columns>
I need to glue content to window sides, would also like to add a gridsplitter to resize internal control separation, and the status bar creates whitespace.
The Grid won't resize vertically with the bottom of the window for instance.
Currently, I am yet unaware of the cause or resolution, starting to go blind on the code. I could use a second pair of eyes.
Change Heights into MinHeights, use Grid containers, etc.
Pretty much anything I could find and think of, including staring down the code...
<Window x:Class="Teachers_Lounge.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:Teachers_Lounge"
mc:Ignorable="d"
Title="Teachers Lounge"
Height="625"
Width="1525"
MinHeight="625"
MinWidth="1525"
KeyDown="Window_KeyDown"
Closing="Window_Closing" Loaded="Window_Loaded">
<Window.Resources>
<DataTemplate x:Key="CalendarTemplate">
<Grid Margin="1">
<Grid.RowDefinitions>
<RowDefinition Height="20" />
<RowDefinition Height="20" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="265" />
<ColumnDefinition Width="50" />
</Grid.ColumnDefinitions>
<DockPanel Grid.Row="0" Grid.Column="0">
<TextBlock FontWeight="Bold" Text="Name:" DockPanel.Dock="Left" Margin="5,0,10,0" />
<TextBlock Text="" />
<TextBlock Text="{Binding EventName}" Foreground="Green" FontWeight="Bold" />
</DockPanel>
<DockPanel Grid.Row="1" Grid.Column="0">
<TextBlock FontWeight="Bold" Text="Date:" Foreground="DarkGray" DockPanel.Dock="Left" Margin="5,0,5,0" />
<TextBlock Text="{Binding EventDateTime}" />
</DockPanel>
<Grid Grid.Column="1" Grid.RowSpan="2" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="-5,0,5,0">
<Button x:Name="EditEvent_Button" Width="40" Height="15" Margin="0,5,0,0" VerticalAlignment="Top" BorderThickness="0" Background="LightGray" CommandParameter="{Binding}" Command="{Binding ElementName=Window, Path=OnClickEditEvent}" Click="EditEvent_Button_Click">
<TextBlock Margin="0, -2">Edit</TextBlock>
</Button>
<Button x:Name="DeleteEvent_Button" Width="40" Height="15" Margin="0,20,0,5" VerticalAlignment="Bottom" BorderThickness="0" Background="LightGray" CommandParameter="{Binding}" Command="{Binding ElementName=Window, Path=OnClickDeleteEvent}" Click="DeleteEvent_Button_Click">
<TextBlock Margin="0, -2">Delete</TextBlock>
</Button>
</Grid>
</Grid>
</DataTemplate>
</Window.Resources>
<Grid MinHeight="586" VerticalAlignment="Top">
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="*" />
<RowDefinition Height="20" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="360" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBox x:Name="DateAndTime" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" Height="30" Margin="10,10,0,0" TextWrapping="Wrap" Text="dddd dd mmmm HHh" VerticalAlignment="Top" Width="350" FontSize="20" IsEnabled="False"/>
<TextBox x:Name="Topic" Grid.Row="0" Grid.Column="1" Margin="10,10,77,10" TextWrapping="Wrap" Text="Topic" FontSize="20" FontWeight="Bold" KeyDown="Topic_KeyDown" LostFocus="Topic_LostFocus" />
<Button x:Name="Settings_Button" Grid.Column="1" Margin="0,10,10,10" FontWeight="Bold" Click="Settings_Button_Click" HorizontalAlignment="Right" Width="62">Settings</Button>
<Grid Grid.Row="1" Grid.Column="0"
Margin="10,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="20" />
<RowDefinition Height="489*" />
<RowDefinition Height="7*"/>
</Grid.RowDefinitions>
<Menu BorderThickness="1 1 1 0" BorderBrush="Black">
<Menu.ItemsPanel>
<ItemsPanelTemplate>
<DockPanel HorizontalAlignment="Stretch"/>
</ItemsPanelTemplate>
</Menu.ItemsPanel>
<MenuItem Header="New Event" Click="NewReplacement_Click" />
</Menu>
<ListBox x:Name="CalendarList" Grid.Row="1"
BorderThickness="1 0 1 1" BorderBrush="Black"
HorizontalAlignment="Left" MinWidth="350" MinHeight="485" VerticalAlignment="Top"
ItemsSource="{Binding Tables[0]}" ItemTemplate="{StaticResource CalendarTemplate}" KeyDown="CalendarList_KeyDown"/>
</Grid>
<Grid Grid.Row="1" Grid.Column="1"
HorizontalAlignment="Left" MinHeight="485" MinWidth="1072" VerticalAlignment="Top" Margin="10,0,10,0">
<Grid.RowDefinitions>
<RowDefinition Height="20" />
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Menu BorderThickness="1 1 1 0" BorderBrush="Black">
<Menu.ItemsPanel>
<ItemsPanelTemplate>
<DockPanel HorizontalAlignment="Stretch"/>
</ItemsPanelTemplate>
</Menu.ItemsPanel>
<MenuItem Header="🠜" Click="ExcelPreviousDate_Click" />
<MenuItem Header="🡄" Click="ExcelPreviousWeek_Click" />
<MenuItem x:Name="ExcelActiveTimewindow" Header="Week XX, Date dd-MM-yy" IsEnabled="False" />
<MenuItem Header="🡆" Click="ExcelNextWeek_Click" />
<MenuItem Header="🠞" Click="ExcelNextDate_Click" />
<Separator />
<MenuItem Header="New Replacement" Click="NewReplacement_Click" />
<MenuItem Header="Delete Replacements" HorizontalAlignment="Right" Click="DeleteReplacements_Click" />
</Menu>
<DataGrid Name="ExcelDataView" Grid.Row="1"
BorderThickness="1 0 1 1" BorderBrush="Black"
AutoGenerateColumns="False"
ColumnWidth="*"
RowBackground="WhiteSmoke"
Background="LightBlue"
CanUserAddRows="False"
BeginningEdit="ExcelDataView_BeginningEdit"
CellEditEnding="ExcelDataView_CellEditEnding"
RowEditEnding="ExcelDataView_RowEditEnding"
SelectionChanged="ExcelDataView_SelectionChanged"
MinWidth="1077" MinHeight="485" HorizontalAlignment="Left" VerticalAlignment="Top">
<DataGrid.ColumnHeaderStyle>
<Style TargetType="DataGridColumnHeader">
<EventSetter Event="Click" Handler="OnExcelHeaderClicked" />
</Style>
</DataGrid.ColumnHeaderStyle>
<DataGrid.Columns>
<DataGridTextColumn Header="Time" Binding="{Binding TimeText, Mode=TwoWay}" Width="70" CanUserSort="False" />
<DataGridTextColumn Header="Replaced User" Binding="{Binding ReplacedUser, Mode=TwoWay}" Width="140" CanUserSort="False" />
<DataGridTextColumn Header="Replacement User" Binding="{Binding ReplacementUser, Mode=TwoWay}" Width="140" CanUserSort="False" />
<DataGridTextColumn Header="Class" Binding="{Binding Class, Mode=TwoWay}" Width="170" CanUserSort="False" />
<DataGridTextColumn Header="Location" Binding="{Binding Location, Mode=TwoWay}" Width="170" CanUserSort="False" />
<DataGridTextColumn Header="Info" Binding="{Binding AdditionalInfo, Mode=TwoWay}" CanUserSort="False" />
<DataGridCheckBoxColumn Header="Mark" Binding="{Binding Marked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" CanUserSort="False" Width="50">
<DataGridCheckBoxColumn.CellStyle>
<Style>
<EventSetter Event="CheckBox.Checked" Handler="OnExcelDeleteColumnChecked"/>
<EventSetter Event="CheckBox.Unchecked" Handler="OnExcelDeleteColumnUnchecked"/>
</Style>
</DataGridCheckBoxColumn.CellStyle>
</DataGridCheckBoxColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
<Menu Grid.Row="3" Grid.ColumnSpan="2"
BorderThickness="0 1 0 0" BorderBrush="Black" IsEnabled="False"
VerticalAlignment="Bottom" Height="20">
<Menu.ItemsPanel>
<ItemsPanelTemplate>
<DockPanel HorizontalAlignment="Stretch"/>
</ItemsPanelTemplate>
</Menu.ItemsPanel>
<MenuItem MinWidth="1111" BorderThickness="0">
<MenuItem.Header>
<TextBlock x:Name="StatusbarMessage"
HorizontalAlignment="Left" VerticalAlignment="Center"
TextAlignment="Left" />
</MenuItem.Header>
</MenuItem>
<MenuItem BorderThickness="0"
HorizontalAlignment="Right" HorizontalContentAlignment="Right" Width="350" >
<MenuItem.Header>
<TextBlock x:Name="StatusbarInfo"
VerticalAlignment="Center" Width="335"
TextAlignment="Right" />
</MenuItem.Header>
</MenuItem>
</Menu>
</Grid>
</Window>
A proper layout that resizes as it should is what I'd expect.
Some weird behavior and glue-ing are what is happening though.
This is my main window code it has one browse button and this button also display on user control but I don't want to show that button and space taken by that button in user control
<Window x:Class="Take_Out_Info.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Take Out Info" Height="auto" Width="auto"
Closing="Window_Closing" WindowState="Maximized">
<Window.Resources>
<Style x:Key="menuitem" TargetType="MenuItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type MenuItem}">
<Border x:Name="Bd" Padding="17,0,17,0" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True" Uid="Border_38">
<ContentPresenter x:Name="ContentPresenter" Content="{TemplateBinding Header}" Grid.Column="1" ContentSource="Header" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Uid="ContentPresenter_33"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Opacity" Value="0.8"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Grid Background="#b5d2fc">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" >
<Menu Name="browsemenu" DockPanel.Dock="Top" Opacity="1" Height="50" Background="#1389e4" >
<MenuItem x:Name="browse" Width="140" Margin="10,10,10,10" HorizontalAlignment="Center" Style="{StaticResource menuitem}" Click="browse_Click" Height="30" Background="white" BorderThickness="2" BorderBrush="black">
<MenuItem.Header>
<TextBlock Width="90" TextAlignment="Center" VerticalAlignment="CENTER" Foreground="#1389e4" FontWeight="Bold" HorizontalAlignment="Center" FontSize="15" ><Run Text="Browse"/></TextBlock>
</MenuItem.Header>
</MenuItem>
</Menu>
</Grid>
<Grid Grid.Row="1" >
<ContentControl x:Name="DetailsControl" Margin="0" HorizontalAlignment="Left" VerticalAlignment="Top" />
</Grid>
</Grid>
</Window>
this image is my main window
This is my user control code
<UserControl x:Class="Take_Out_Info.BrowseFile"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:adorners="http://gu.se/Adorners"
Height="auto" Width="auto">
<Grid Background="#b5d2fc">
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="50"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid Width="auto" Background="#1389e4">
<Button Grid.Row="0" Content="Browse" Name="btnBrowse" Click="btnBrowse_Click" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0" Height="27" Width="140" Background="White" FontSize="15" BorderThickness="2" BorderBrush="Black" />
<Button Grid.Row="0" Content="Search" Name="btnSearch" Click="btnSearch_Click" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="190,0,0,0" Height="27" Width="140" Background="White" FontSize="15" BorderThickness="2" BorderBrush="Black" />
<Button Grid.Row="0" Content="Reset" Name="btnReset" Click="btnReset_Click" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="370,0,0,0" Height="27" Width="140" Background="White" FontSize="15" BorderThickness="2" BorderBrush="Black" />
<ContentControl x:Name="DetailsControl" VerticalAlignment="Top" HorizontalAlignment="Left" Width="0" />
</Grid>
<Grid Grid.Row="1" Width="auto">
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBox Name="txtDayfind" adorners:Watermark.Text="Search Day Here" Grid.Row="1" Grid.Column="0" Margin="-10,0,0,0" Height="24" Width="120"/>
<Button Name="btnDayfind" Grid.Row="1" Grid.Column="0" Margin="110,0,0,0" Height="24" Width="24" Click="btnDayfind_Click">
<Image Source="002-search.png"></Image>
</Button>
<Button Name="btnDayReset" Grid.Row="1" Grid.Column="0" Margin="157,0,0,0" Height="24" Width="24" Click="btnDayReset_Click">
<Image Source="001-multiply.png"></Image>
</Button>
<TextBox Name="txtDatefind" adorners:Watermark.Text="Search Date Here" Grid.Row="0" Grid.Column="1" Margin="-10,0,0,0" Height="24" Width="120"/>
<Button Name="btnDatefind" Grid.Row="0" Grid.Column="1" Margin="121,0,0,0" Height="24" Width="24" Click="btnDatefind_Click">
<Image Source="002-search.png"></Image>
</Button>
<Button Name="btnDateReset" Grid.Row="0" Grid.Column="1" Margin="170,0,0,0" Height="24" Width="24" Click="btnDateReset_Click">
<Image Source="001-multiply.png"></Image>
</Button>
<TextBox Name="txtTimefind" adorners:Watermark.Text="Search Time Here" Grid.Row="0" Grid.Column="2" Margin="-10,0,0,0" Height="24" Width="120"/>
<Button Name="btnTimefind" Grid.Row="0" Grid.Column="2" Margin="121,0,0,0" Height="24" Width="24" Click="btnTimefind_Click">
<Image Source="002-search.png"></Image>
</Button>
<Button Name="btnTimeReset" Grid.Row="0" Grid.Column="2" Margin="170,0,0,0" Height="24" Width="24" Click="btnTimeReset_Click">
<Image Source="001-multiply.png"></Image>
</Button>
<TextBox Name="txtLatfind" adorners:Watermark.Text="Search Lat Here" Grid.Row="0" Grid.Column="3" Margin="-10,0,0,0" Height="24" Width="120"/>
<Button Name="btnLatfind" Grid.Row="0" Grid.Column="3" Margin="121,0,0,0" Height="24" Width="24" Click="btnLatfind_Click">
<Image Source="002-search.png"></Image>
</Button>
<Button Name="btnLatReset" Grid.Row="0" Grid.Column="3" Margin="170,0,0,0" Height="24" Width="24" Click="btnLatReset_Click">
<Image Source="001-multiply.png"></Image>
</Button>
<TextBox Name="txtLongfind" adorners:Watermark.Text="Search Long Here" Grid.Row="0" Grid.Column="4" Margin="-10,0,0,0" Height="24" Width="120"/>
<Button Name="btnLongfind" Grid.Row="0" Grid.Column="4" Margin="121,0,0,0" Height="24" Width="24" Click="btnLongfind_Click">
<Image Source="002-search.png"></Image>
</Button>
<Button Name="btnLongReset" Grid.Row="0" Grid.Column="4" Margin="170,0,0,0" Height="24" Width="24" Click="btnLongReset_Click">
<Image Source="001-multiply.png"></Image>
</Button>
<TextBox Name="txtAddressfind" adorners:Watermark.Text="Search Address Here" Grid.Row="0" Grid.Column="5" Margin="-15,0,0,0" Height="24" Width="120"/>
<Button Name="btnAddressfind" Grid.Row="0" Grid.Column="5" Margin="121,0,0,0" Height="24" Width="24" Click="btnAddressfind_Click">
<Image Source="002-search.png"></Image>
</Button>
<Button Name="btnAddressReset" Grid.Row="0" Grid.Column="5" Margin="170,0,0,0" Height="24" Width="24" Click="btnAddressReset_Click">
<Image Source="001-multiply.png"></Image>
</Button>
<TextBox Name="txtTypefind" adorners:Watermark.Text="Search Type Here" Grid.Row="0" Grid.Column="6" Margin="-10,0,0,0" Height="24" Width="120"/>
<Button Name="btnTypefind" Grid.Row="0" Grid.Column="6" Margin="121,0,0,0" Height="24" Width="24" Click="btnTypefind_Click">
<Image Source="002-search.png"></Image>
</Button>
<Button Name="btnTypeReset" Grid.Row="0" Grid.Column="6" Margin="170,0,0,0" Height="24" Width="24" Click="btnTypeReset_Click">
<Image Source="001-multiply.png"></Image>
</Button>
</Grid>
<TabControl x:Name="tabControl1" Grid.Row="2" Grid.Column="1" Height="auto" Width="auto" ItemsSource="{Binding tabs}" SelectedItem="{Binding SelectedEvaluation}" TabStripPlacement="Top" >
<TabControl.ContentTemplate >
<DataTemplate>
<DataGrid x:Name="dataGrid1" Height="auto" Width="auto" ItemsSource="{Binding}" AutoGenerateColumns="False" >
<DataGrid.Columns>
<DataGridTextColumn Width="*" Header="Day" Binding="{Binding [Day]}"/>
<DataGridTextColumn Width="*" Header="Date" Binding="{Binding [Date]}"/>
<DataGridTextColumn Width="*" Header="Time" Binding="{Binding [Time]}"/>
<DataGridTextColumn Width="*" Header="Lat" Binding="{Binding [Lat]}"/>
<DataGridTextColumn Width="*" Header="Long" Binding="{Binding [Long]}"/>
<DataGridTextColumn Width="*" Header="Address" Binding="{Binding [Address]}"/>
<DataGridTextColumn Width="*" Header="Type" Binding="{Binding [Type]}"/>
</DataGrid.Columns>
</DataGrid>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
</Grid>
</UserControl>
What to do for getting output like image 3.I to want to remove that browse button which is in blue color and also space has taken on user control for that window.
User control takes the only controls of user control and not of the main window.
It can only show user-control controls and not of main windows control when opening on user control window.
Maybe you should remove this below Grid from XAML source:
<Grid Background="#b5d2fc">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" >
<Menu Name="browsemenu" DockPanel.Dock="Top" Opacity="1" Height="50" Background="#1389e4" >
<MenuItem x:Name="browse" Width="140" Margin="10,10,10,10" HorizontalAlignment="Center" Style="{StaticResource menuitem}" Click="browse_Click" Height="30" Background="white" BorderThickness="2" BorderBrush="black">
<MenuItem.Header>
<TextBlock Width="90" TextAlignment="Center" VerticalAlignment="CENTER" Foreground="#1389e4" FontWeight="Bold" HorizontalAlignment="Center" FontSize="15" ><Run Text="Browse"/></TextBlock>
</MenuItem.Header>
</MenuItem>
</Menu>
</Grid>
<Grid Grid.Row="1" >
<ContentControl x:Name="DetailsControl" Margin="0" HorizontalAlignment="Left" VerticalAlignment="Top" />
</Grid>
</Grid>
If No , You can set 0 for <RowDefinition Height="50"/>
You can disable visibility of browse MenuItem's on click event(browse_Click) of mainwindow xaml page like below
private void browse_Click(object sender, RoutedEventArgs e)
{
browse.Visibility = Visibility.Collapsed;
}
I have the following control, the first row is a header row. There will always be at least one additional row. (minimum of 2 total rows).
I've thought about making the content row into a UserControl but unsure about how to set the content of the UserControl into the two columns. (Stack in Column 0 and TriggerForWord in Column 1)
What is the best way to implement adding rows dynamically and setting the content? UserControl loaded into each row? Something else?
<Grid Grid.Row="3" Margin="10,10,10,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding Source={x:Static localization:Resources.WordToTriggerAction}}" Margin="2 8 2 8" FontWeight="SemiBold" />
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Source={x:Static localization:Resources.Trigger}}" Margin="12 8 2 8" FontWeight="SemiBold" />
<!-- dynamic part -->
<StackPanel x:Name="Stack" Orientation="Horizontal" Grid.Row="1" Grid.Column="0" Margin="0,0,10,20" VerticalAlignment="Top">
<telerik:RadAutoCompleteBox x:Name="WordForAction" Width="300" WatermarkContent="{Binding Source={x:Static localization:Resources.EnterWordForAction}}" Margin="0" ItemsSource="{Binding Path=Words}"
DisplayMemberPath="word" SelectionMode="Single" AutoCompleteMode="Append" SearchTextChanged="WordForAction_SearchTextChanged" />
<Button IsEnabled="{Binding Path=SearchText.Length, ElementName=WordForAction}" IsTabStop="False" Height="{Binding Path=ActualHeight, ElementName=WordForAction}" FontFamily="{StaticResource TelerikWebUI}" FontSize="15" Content="{StaticResource GlyphPlus}" ToolTip="{Binding Source={x:Static localization:Resources.AddWord}}" VerticalAlignment="Bottom" />
<Button IsEnabled="{Binding Path=SearchText.Length, ElementName=WordForAction}" IsTabStop="False" Height="{Binding Path=ActualHeight, ElementName=WordForAction}" FontFamily="{StaticResource TelerikWebUI}" FontSize="15" Content="{StaticResource GlyphMinus}" ToolTip="{Binding Source={x:Static localization:Resources.RemoveWord}}" VerticalAlignment="Bottom" />
</StackPanel>
<telerik:RadComboBox x:Name="TriggerForWord" Grid.Row="1" Grid.Column="1" Width="150" EmptyText="{Binding Source={x:Static localization:Resources.Trigger}}" IsEditable="False" IsEnabled="False" SelectedValuePath="uuid" SelectionChanged="TriggerForWord_SelectionChanged"
Height="{Binding ElementName=WordForAction, Path=ActualHeight}" Margin="10 0 0 0" ItemsSource="{Binding Path=Triggers}" DisplayMemberPath="description" VerticalAlignment="Top" />
</Grid>
For other folks who come this way ...
<Grid Grid.Row="3" Margin="0,10,0,0" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="310"/>
<ColumnDefinition Width="150"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding Source={x:Static localization:Resources.WordToTriggerAction}}" Margin="2 8 2 8" FontWeight="SemiBold" />
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Source={x:Static localization:Resources.Trigger}}" Margin="2 8 2 8" FontWeight="SemiBold" />
<ItemsControl Grid.Row="1" Grid.ColumnSpan="2" ItemsSource="{Binding Path=WordsForAction}" x:Name="WordsForActionItems" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0, 0, 0, 5">
<StackPanel Orientation="Horizontal" Margin="0" VerticalAlignment="Top" Width="310">
<telerik:RadAutoCompleteBox x:Name="WordForAction" Width="250" WatermarkContent="{Binding Source={x:Static localization:Resources.EnterWordForAction}}" Margin="0"
ItemsSource="{Binding Path=Words, ElementName=_this}" DisplayMemberPath="Word" SearchText="{Binding Word}"
SelectionMode="Single" AutoCompleteMode="Append" SearchTextChanged="WordForAction_SearchTextChanged" />
<Button Name="AddWord" IsEnabled="True" IsTabStop="False" Height="{Binding Path=ActualHeight, ElementName=WordForAction}" FontFamily="{StaticResource TelerikWebUI}" FontSize="15" Content="{StaticResource GlyphPlus}" Click="AddWord_Click" ToolTip="{Binding Source={x:Static localization:Resources.AddWord}}" VerticalAlignment="Bottom" />
<Button Name="RemoveWord" IsEnabled="{Binding Items.Count, ElementName=WordsForActionItems, Converter={StaticResource CountToBoolConverter}}" IsTabStop="False" Height="{Binding Path=ActualHeight, ElementName=WordForAction}" FontFamily="{StaticResource TelerikWebUI}" FontSize="15" Content="{StaticResource GlyphMinus}" Click="RemoveWord_Click" ToolTip="{Binding Source={x:Static localization:Resources.RemoveWord}}" VerticalAlignment="Bottom" />
</StackPanel>
<telerik:RadComboBox Grid.Column="1" x:Name="TriggerForWord" Width="150" EmptyText="Trigger" IsEditable="False" IsEnabled="True" SelectionChanged="TriggerForWord_SelectionChanged"
Margin="0" ItemsSource="{Binding Path=Triggers, ElementName=_this}" SelectedValuePath="uuid" DisplayMemberPath="description" SelectedValue="{Binding Trigger_uuid}" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
Hi guys i am facing an exception in the following code,this code was working fine but i dont understand what happened to it now:
Exception is :
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: Provide value on 'System.Windows.StaticResourceExtension' threw an exception.
<UserControl x:Class="AFIC.View.WirelessConfigurationView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:res="clr-namespace:AFIC.Resources"
xmlns:view="clr-namespace:AFIC.View"
xmlns:viewmodel="clr-namespace:AFIC.ViewModel"
>
<UserControl.Resources>
<Style TargetType="{x:Type Button}">
<Setter Property="Height" Value="30"/>
<Setter Property="FontFamily" Value="Arial"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Foreground" Value="Black"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="Transparent">
<ContentPresenter
x:Name="contentPresenter"
ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="400" />
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="1" Margin="0,10">
<StackPanel Height="550" Orientation="Vertical" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="170"/>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="65"/>
<ColumnDefinition Width="205"/>
</Grid.ColumnDefinitions>
<Label
Grid.Row="0"
Grid.ColumnSpan="1"
HorizontalAlignment="Left"
Content="IP Configuration:"
Foreground="Black"
FontWeight="ExtraBold"
FontSize="14"
Opacity="0.8"
/>
<Label
Grid.Row="1"
Grid.Column="0"
VerticalAlignment="Center"
Content="Wireless IP Address"
Foreground="Black"
Opacity="0.8"
/>
<Grid
Grid.Column="1"
Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="40"/>
<ColumnDefinition Width="40"/>
<ColumnDefinition Width="40"/>
<ColumnDefinition Width="40"/>
</Grid.ColumnDefinitions>
<TextBox
Grid.Row="1"
Grid.Column="0"
VerticalAlignment="Center"
MaxLength="3"
Width="30"
Foreground="Black"
Opacity="0.8"
Text="{Binding WirelessIP1,UpdateSourceTrigger=PropertyChanged}"
/>
<TextBox
Grid.Row="1"
Grid.Column="1"
VerticalAlignment="Center"
MaxLength="3"
Width="30"
Foreground="Black"
Opacity="0.8"
Text="{Binding WirelessIP2,UpdateSourceTrigger=PropertyChanged}"
/>
<TextBox
Grid.Row="1"
Grid.Column="2"
VerticalAlignment="Center"
MaxLength="3"
Width="30"
Foreground="Black"
Opacity="0.8"
Text="{Binding WirelessIP3,UpdateSourceTrigger=PropertyChanged}"
/>
<TextBox
Grid.Row="1"
Grid.Column="4"
VerticalAlignment="Center"
MaxLength="3"
Width="30"
Foreground="Black"
Opacity="0.8"
Text="{Binding WirelessIP4,UpdateSourceTrigger=PropertyChanged}"
/>
</Grid>
<Label
Grid.Row="2"
Grid.ColumnSpan="1"
HorizontalAlignment="Left"
Content="AP Group Configuration"
Foreground="Black"
FontWeight="ExtraBold"
FontSize="14"
Opacity="0.8"
/>
<Label
Grid.Row="3"
Grid.Column="0"
VerticalAlignment="Center"
Content="Group ID"
Foreground="Black"
Opacity="0.8"
Margin="0,0,0,5"
/>
<TextBox
Grid.Row="3"
Grid.Column="1"
VerticalAlignment="Center"
Margin="0,0,0,5"
Text="{Binding GroupId,UpdateSourceTrigger=PropertyChanged}"
/>
<Label
Grid.Row="3"
Grid.Column="2"
VerticalAlignment="Center"
Content="(1-1024)"
Foreground="Black"
Opacity="0.8"
Margin="0,0,0,5"
/>
<Label
Grid.Row="4"
Grid.Column="0"
VerticalAlignment="Center"
Content="AP Hardware Type"
Foreground="Black"
Opacity="0.8"
/>
<ComboBox
Grid.Row="4"
Grid.Column="1"
ItemsSource="{Binding AvailableHwTypes}"
SelectedItem="{Binding SelectedApHardwareType}"
>
</ComboBox>
<Button
Grid.Row="4"
Grid.Column="2"
Margin="10,0,0,0"
Command=""
Style="{StaticResource AddHwType}">
Add
</Button>
<Button
Grid.Row="6"
Grid.Column="3"
Margin="10,0,0,0"
Style="{StaticResource AppButtons}"
Command="{Binding ConfigWireless}">
Configuration
</Button>
<TextBox
Grid.Row="5"
Grid.ColumnSpan="3"
IsReadOnly="True"
IsEnabled="False"
Visibility="Hidden"
Height="10"/>
<DataGrid
Grid.Row="6"
Grid.ColumnSpan="3"
Height="100"
AutoGenerateColumns="False"
ItemsSource="{Binding wirelessconfiguration}"
SelectedValue="{Binding SelectedWireless}"
Name="dg"
>
<DataGrid.Columns>
<DataGridTextColumn Width="100" Header="S.No" Binding="{Binding Path=S_No}"/>
<DataGridTextColumn Width="100" Header="Group ID" Binding="{Binding Path=_groupId}"/>
<DataGridTextColumn Width="200" Header="AP Hardware Type" Binding="{Binding Path=_apHardwareType}"/>
</DataGrid.Columns>
</DataGrid>
<Label
Grid.Row="7"
Grid.Column="0"
HorizontalAlignment="Left"
Content="Network Configuration"
FontWeight="ExtraBold"
Foreground="Black"
FontSize="14"
Opacity="0.8"
/>
<Label
Grid.Row="8"
Grid.Column="0"
VerticalAlignment="Center"
Content="SSID"
Foreground="Black"
Opacity="0.8"
/>
<TextBox
Grid.Row="8"
Grid.Column="1"
VerticalAlignment="Center"
Text="Guest Network"
/>
<Label
Grid.Row="9"
Grid.Column="0"
VerticalAlignment="Center"
Content="Security"
Foreground="Black"
Opacity="0.8"
/>
<ComboBox
Margin="0,5,0,8"
Grid.Row="9"
Grid.Column="1"
ItemsSource="{Binding ACAvailableSecurityTypes}"
SelectedItem="{Binding ACSelectedSecurityType}"
>
</ComboBox>
<view:ACSecurityStaticWEP
Grid.Row="11"
Grid.ColumnSpan="3"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Visibility="{Binding IsACStaticWep, Converter={StaticResource BooleanToVisibilityConverter}}"
/>
<view:ACSecurityTypeWepIEEE
Grid.Row="11"
Grid.ColumnSpan="3"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Visibility="{Binding IsACWEPIEEE, Converter={StaticResource BooleanToVisibilityConverter}}"
/>
<view:ACSecurityTypeWPAUC
Grid.Row="11"
Grid.ColumnSpan="3"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Visibility="{Binding IsACWPAPersonal, Converter={StaticResource BooleanToVisibilityConverter}}"
/>
<view:ACSecurityTypEnterprise
Grid.Row="11"
Grid.ColumnSpan="3"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Visibility="{Binding IsACWPAEnterprise, Converter={StaticResource BooleanToVisibilityConverter}}"
/>
</Grid>
</StackPanel>
</ScrollViewer>
</Grid>
</UserControl>
Can anyone tell me where is the problem.Any help would be highly appreciable.
It seems that one of the StaticResources used does not exist:
Either:
AddHwType (Button Style)
AppButtons (Button Style)
BooleanToVisibilityConverter (Converter)
You might miss a merged dictionary somewhere or forgot to add a resource before using it. Review the XAML Resources page on MSDN for more info.
Solved:I was using wrong Static Resource i was writingStyle="{StaticResource AddHwType }" and it should be Style="{StaticResource AppButtons}" :)