Related
I am developing a UWP application. I want to have a command bar with a back and forward button to help users navigate back and fore. However, the UI did not turn out what I am trying to achieve.
This is what I am trying to achieve:
This is how my UI looks like now:
The back and forward are displayed as text instead of icons and they are on the right side of the commandbar.
Here is my XAML code:
<CommandBar IsSticky="True"
IsOpen="True"
Name="WebViewCommandBar"
Background="{StaticResource CitiKioskBackgroundBrush}"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom">
<CommandBar.Transitions>
<TransitionCollection>
</TransitionCollection>
</CommandBar.Transitions>
<CommandBar.PrimaryCommands>
<AppBarToggleButton Label="Instagram"
IsCompact="True"
IsChecked="True"
Name="WebViewInstagramButton"
Click="WebViewInstagramButton_Click">
<AppBarToggleButton.Icon>
<PathIcon HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="White"
Data="M9.97867488861084,7.20437383651733L9.54365062713623,7.2351450920105 7.79691314697266,8.17826080322266 7.2708568572998,9.02131462097168 7.07487726211548,10.0166091918945 7.36349153518677,11.3397054672241 8.1572790145874,12.3524122238159 8.19353580474854,12.381049156189 8.2119779586792,12.3956165313721 9.94506454467773,12.9863567352295 11.0567455291748,12.7660837173462 11.979341506958,12.1575241088867 12.6106977462769,11.2597017288208 12.8486633300781,10.1716403961182 12.6326217651367,9.01014423370361 12.0255851745605,8.06982421875 11.1125907897949,7.43859577178955 9.97867488861084,7.20437383651733z M0.204548388719559,7.13297843933105L5.68732500076294,7.13850927352905 5.78951168060303,7.15514135360718 4.90260219573975,9.44109153747559 5.18843698501587,11.8609714508057 6.01344013214111,13.3186454772949 7.28439044952393,14.4163703918457 8.83327960968018,15.0481796264648 10.4646596908569,15.1450786590576 12.0411882400513,14.7238512039185 13.4255237579346,13.8012838363647 14.4520330429077,12.4383029937744 14.9794578552246,10.7761964797974 14.8979682922363,8.96072196960449 14.0977325439453,7.13763618469238 15.5856904983521,7.13763618469238 19.6856136322021,7.13337802886963 19.9149150848389,7.36137056350708 19.9090938568115,16.1435375213623 19.5959320068359,17.6298408508301 18.7542190551758,18.8571910858154 17.5204677581787,19.6917743682861 16.0311851501465,19.9997787475586 3.90109658241272,19.9998149871826 2.40375375747681,19.6914520263672 1.16712784767151,18.8549728393555 0.325676739215851,17.6230506896973 0.0138576431199908,16.1283626556396 0.0112377209588885,7.37043046951294 0.204548388719559,7.13297843933105z M9.96401309967041,6.16715049743652L11.4818696975708,6.47564172744751 12.7234716415405,7.31509256362915 13.5634679794312,8.55998802185059 13.8765115737915,10.0848112106323 13.5733013153076,11.6170873641968 12.7314901351929,12.8659477233887 11.4762935638428,13.7066211700439 9.93292427062988,14.0143356323242 8.41271877288818,13.7068710327148 7.16936302185059,12.8687133789063 6.32838821411133,11.6252336502075 6.01532745361328,10.1018056869507 6.32141780853271,8.57305812835693 7.16788578033447,7.32167959213257 8.4252462387085,6.47670030593872 9.96401309967041,6.16715049743652z M16.4200878143311,1.65452766418457L15.3651809692383,1.66138708591461 14.9484748840332,1.80187773704529 14.948450088501,1.80190110206604 14.7337226867676,2.30761909484863 14.7330675125122,3.37468886375427 14.7339963912964,4.44175672531128 15.3758811950684,5.07638740539551 17.4615039825439,5.076096534729 18.0673847198486,4.64739370346069 18.0673961639404,4.64735555648804 18.0954151153564,4.45471143722534 18.0955257415771,2.29634284973145 17.9235496520996,1.84173333644867 17.4749870300293,1.66186022758484 16.4200878143311,1.65452766418457z M5.45150232315063,1.6658582353557E-06L16.0992107391357,0.00618810812011361 17.4747848510742,0.288062632083893 18.6524124145508,1.04852998256683 19.4996070861816,2.16558766365051 19.8838844299316,3.51723384857178 19.9140892028809,6.37719964981079 19.7212162017822,6.53466606140137 17.1017303466797,6.53331756591797 13.8273859024048,6.53597354888916 13.4012060165405,6.37417888641357 11.7566804885864,5.34520387649536 9.91614151000977,5.01156997680664 8.0790958404541,5.3713493347168 6.44505453109741,6.42261552810669 6.14584589004517,6.53517389297485 0.227764710783958,6.53313541412354 0.00923560187220573,6.37843608856201 0.0454814843833447,3.49474239349365 0.531499147415161,1.96258723735809 1.61619710922241,0.766114294528961 1.68897974491119,0.753560423851013 1.68432188034058,4.7226996421814 1.92075479030609,4.95895290374756 2.40411639213562,4.88502788543701 2.4732460975647,4.41035175323486 2.47342801094055,0.481098204851151 2.68695402145386,0.209208399057388 3.01554799079895,0.128100618720055 3.05434131622314,0.323522448539734 3.05630588531494,4.17981147766113 3.05630588531494,4.34957885742188 3.13063049316406,4.8825216293335 3.65079236030579,4.95818901062012 3.86742925643921,4.74373435974121 3.86342668533325,2.560866355896 3.85738492012024,0.208162307739258 3.95179295539856,0.00864517875015736 4.15400981903076,0.00509752612560987 4.34406280517578,0.0164247378706932 4.42144870758057,0.213619664311409 4.41020441055298,4.7006459236145 4.6572642326355,4.95935249328613 5.15134286880493,4.88273048400879 5.22201919555664,4.39266538619995 5.21823406219482,0.245279848575592 5.45150232315063,1.6658582353557E-06z" />
</AppBarToggleButton.Icon>
</AppBarToggleButton>
<AppBarToggleButton Label="Facebook"
IsCompact="True"
Foreground="White"
Name="WebViewFacebookButton"
Click="WebViewBackButton_Click">
<AppBarToggleButton.Icon>
<PathIcon HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M1.02904176712036,0L18.7531337738037,0 19.4806938171387,0.334847688674927 19.7821369171143,1.14315927028656 19.7821369171143,18.8567867279053 19.4806938171387,19.6652908325195 18.7531337738037,20 13.6363229751587,20 13.6363229751587,11.7826108932495 16.0952949523926,11.7826108932495 16.0952949523926,9.11336040496826 13.6363229751587,9.11336040496826 13.6363229751587,8.21858692169189 13.9752616882324,7.38667869567871 14.7947940826416,7.04201602935791 16.0952949523926,7.04201602935791 16.0952949523926,4.3735990524292 13.2796297073364,4.3735990524292 12.0740346908569,4.6205849647522 11.0897855758667,5.29418992996216 10.4263172149658,6.29338455200195 10.1830644607544,7.51713943481445 10.1830644607544,9.11336040496826 7.96399402618408,9.11336040496826 7.96399402618408,11.7826108932495 10.1830644607544,11.7826108932495 10.1830644607544,20 1.02904176712036,20 0.301447361707687,19.6652908325195 0,18.8567867279053 0,1.14315927028656 0.301447361707687,0.334847688674927 1.02904176712036,0z" />
</AppBarToggleButton.Icon>
</AppBarToggleButton>
<AppBarToggleButton Label="Twitter"
IsCompact="True"
Foreground="White"
Name="WebViewTwitterButton"
Click="WebViewTwitterButton_Click">
<AppBarToggleButton.Icon>
<PathIcon HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M13.8468732833862,0L15.5061712265015,0.288037329912186 16.8415641784668,1.07007586956024 19.4474983215332,0.247780367732048 18.7480487823486,1.32465946674347 17.6431274414063,2.12260270118713 20,1.58885657787323 17.9524993896484,3.34315156936646 17.9643726348877,3.78167033195496 17.7722911834717,5.48182535171509 17.2015743255615,7.17769765853882 14.9573802947998,10.2823972702026 11.2980880737305,12.5473728179932 8.95849895477295,13.1935911178589 6.28999710083008,13.4242305755615 2.9569149017334,13.0233716964722 0,11.901442527771 0.97906106710434,11.948938369751 3.72105479240417,11.564435005188 6.07468605041504,10.4981575012207 3.68070244789124,9.81594848632813 2.24156379699707,8.14456653594971 3.01405906677246,8.20546817779541 4.09468650817871,8.08648586273193 2.78844332695007,7.66685819625854 1.74496293067932,6.92400979995728 1.05345439910889,5.93164443969727 0.803127229213715,4.76346588134766 0.803747117519379,4.72113752365112 2.66249656677246,5.14494228363037 1.33671998977661,3.94736123085022 0.836877763271332,2.32392692565918 1.39249801635742,0.620466768741608 3.08804559707642,2.01878547668457 5.10117053985596,3.10660934448242 7.37433338165283,3.83651208877563 9.84999656677246,4.16106796264648 9.74374771118164,3.38883566856384 10.0662136077881,2.06980514526367 10.9455833435059,0.992617785930634 12.2498168945313,0.266330569982529 13.8468732833862,0z" />
</AppBarToggleButton.Icon>
</AppBarToggleButton>
<AppBarToggleButton Label="YouTube"
IsCompact="True"
Foreground="White"
Name="WebViewYouTubeButton"
Click="WebViewYouTubeButton_Click">
<AppBarToggleButton.Icon>
<PathIcon HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M16.2308826446533,11.0260734558105L16.2910308837891,11.0260734558105 16.7455883026123,11.1358823776245 16.934118270874,11.4334850311279 16.9023532867432,11.9701919555664 15.585147857666,11.9701919555664 15.6151466369629,11.4334850311279 15.7950010299683,11.1417207717896 16.2308826446533,11.0260734558105z M11.9629707336426,10.8395881652832L12.3899412155151,10.9448528289795 12.5768375396729,11.1800594329834 12.5768375396729,13.729118347168 12.3899412155151,13.9585151672363 11.9629707336426,14.0579414367676 11.5342350006104,13.9585151672363 11.3499994277954,13.729118347168 11.3499994277954,11.1800594329834 11.5342350006104,10.9448528289795 11.9629707336426,10.8395881652832z M5.55495595932007,10.4438676834106L5.58686780929565,13.1358976364136 5.57091188430786,13.6674118041992 5.58686780929565,13.9916324615479 5.6444411277771,14.3704557418823 5.9305591583252,14.6947059631348 6.48951435089111,14.8051471710205 7.1193380355835,14.726616859436 7.68892621994019,14.5140590667725 8.06892681121826,14.2223234176636 8.04145526885986,14.7597055435181 9.1788387298584,14.7817640304565 9.1788387298584,10.4438676834106 7.80141115188599,10.4438676834106 7.80141115188599,13.1579847335815 7.81557321548462,13.6121759414673 7.75533771514893,13.8162202835083 7.40013265609741,14.0741624832153 6.95986747741699,13.8369998931885 6.94838237762451,13.6238670349121 6.95986747741699,13.1781320571899 6.93242645263672,10.4438676834106 5.55495595932007,10.4438676834106z M16.2708835601807,10.195897102356L15.9517641067505,10.2138528823853 15.2086753845215,10.4217796325684 14.6275148391724,10.9617357254028 14.4476909637451,11.9058675765991 14.4476909637451,13.2567501068115 15.063383102417,14.4750738143921 16.2582359313965,14.8155889511108 16.3805885314941,14.8155889511108 17.6242637634277,14.3763236999512 18.0282363891602,13.5972213745117 17.9652938842773,13.2567501068115 16.934118270874,13.2567501068115 16.934118270874,13.3659267425537 16.934118270874,13.7499408721924 16.7614707946777,14.0241479873657 16.3504409790039,14.1222648620605 16.1386775970459,14.1222648620605 15.7445592880249,14.0241479873657 15.585147857666,13.7499408721924 15.585147857666,13.7070293426514 15.585147857666,13.2781915664673 15.585147857666,12.7063970565796 17.9652938842773,12.7063970565796 17.9652938842773,12.1021032333374 17.9492664337158,11.4497060775757 17.8776473999023,10.9617357254028 17.5091171264648,10.482852935791 16.7916164398193,10.2365732192993 16.3760280609131,10.1969413757324 16.2708835601807,10.195897102356z M10.0026769638062,8.92857360839844L10.0026769638062,14.7382354736328 11.1400585174561,14.7161769866943 11.2295150756836,14.3542356491089 12.2243089675903,14.7720584869385 12.9736909866333,14.7102937698364 13.4511470794678,14.2606325149536 13.6238822937012,13.5413379669189 13.6238822937012,11.2898817062378 12.9967203140259,10.3678379058838 12.5166177749634,10.2794857025146 11.3792200088501,10.6199560165405 11.3792200088501,8.92857360839844 10.0026769638062,8.92857360839844z M1.3774676322937,8.92857360839844L1.3774676322937,9.67582321166992 2.80273532867432,9.67582321166992 2.80273532867432,14.7817640304565 4.17751502990723,14.7817640304565 4.17751502990723,9.69661808013916 5.82516145706177,9.69661808013916 5.82516145706177,8.92857360839844 1.3774676322937,8.92857360839844z M3.2784264087677,7.3151912689209L16.7110290527344,7.3151912689209 17.9820594787598,7.48477935791016 19.0291175842285,7.93505859375 19.739559173584,8.60498523712158 20,9.42372035980225 20,14.2444114685059 19.739559173584,15.072793006897 19.0291175842285,15.7382345199585 17.9883823394775,16.1879425048828 16.7110290527344,16.3529415130615 3.2784264087677,16.3529415130615 2.0143678188324,16.1879425048828 0.973513185977936,15.7382345199585 0.260436773300171,15.072793006897 0,14.2444114685059 0,9.42372035980225 0.260436773300171,8.60498523712158 0.973513185977936,7.93505859375 2.0143678188324,7.48477935791016 3.2784264087677,7.3151912689209z M9.75994205474854,2.33917641639709L9.33563232421875,2.47822046279907 9.14697074890137,2.81155896186829 9.14697074890137,5.19497060775757 9.32855892181396,5.50879383087158 9.75994205474854,5.64461803436279 10.1895885467529,5.51272058486938 10.3738088607788,5.19497060775757 10.3738088607788,2.81155896186829 10.1895885467529,2.47822046279907 9.75994205474854,2.33917641639709z M12.4572792053223,1.77974998950958L13.7443675994873,1.77974998950958 13.7443675994873,5.2716326713562 13.8781328201294,5.5029559135437 14.2377500534058,5.60170555114746 14.5956478118896,5.5029559135437 14.7497053146362,5.2716326713562 14.7497053146362,1.77974998950958 15.9420595169067,1.77974998950958 15.9420595169067,6.26061725616455 14.4202508926392,6.26061725616455 14.4476909637451,5.89867639541626 14.0437650680542,6.23785305023193 13.5175876617432,6.34766149520874 12.9479999542236,6.23785305023193 12.6043090820313,5.94286775588989 12.5334558486938,5.76089715957642 12.4847345352173,5.57961750030518 12.4572792053223,5.28201484680176 12.4572792053223,4.79988241195679 12.4572792053223,1.77974998950958z M9.68908786773682,1.60298526287079L10.6165437698364,1.73552942276001 11.2295150756836,2.12022066116333 11.4996910095215,2.57051467895508 11.5891618728638,3.30670595169067 11.5891618728638,4.45810317993164 11.4996910095215,5.36066150665283 11.1976470947266,5.9207649230957 10.6165437698364,6.28270578384399 9.75994205474854,6.41392660140991 8.86526489257813,6.30411767959595 8.31163215637207,5.98704385757446 8.00958824157715,5.4906325340271 7.91922092437744,4.59067630767822 7.91922092437744,3.40419125556946 8.06892681121826,2.4061324596405 8.65532398223877,1.82325005531311 9.68908786773682,1.60298526287079z M3.00823521614075,0L4.61158847808838,0 5.5275297164917,2.20727944374084 6.44077920913696,0 8.04145526885986,0 6.31588268280029,2.95322060585022 6.31588268280029,6.39314699172974 4.84897089004517,6.39314699172974 4.84897089004517,2.95322060585022 3.00823521614075,0z" />
</AppBarToggleButton.Icon>
</AppBarToggleButton>
<AppBarSeparator/>
<AppBarButton Icon="Refresh"
Label="Refresh"
IsCompact="True"
Name="WebViewRefreshButton"
Foreground="White"
Click="WebViewRefreshButton_Click"/>
<AppBarButton Icon="DockBottom"
Label="Hide"
IsCompact="True"
Foreground="White"
Name="WebViewHideNavigationButton"
Click="WebViewHideNavigationButton_Click"/>
</CommandBar.PrimaryCommands>
<CommandBar.SecondaryCommands>
<AppBarButton Icon="Back"
Label="Back"
IsCompact="True"
IsEnabled="{Binding CanGoBack,ElementName=webView}"
Name="WebViewBackButton"
Click="WebViewBackButton_Click" />
<AppBarButton Icon="Forward"
Label="Forward"
IsCompact="True"
IsEnabled="{Binding CanGoForward,ElementName=webView}"
Name="WebViewForwardButton"
Click="WebViewForwardButton_Click" />
</CommandBar.SecondaryCommands>
</CommandBar>
You need to set WebViewForwardButton and WebViewBackButton in CommandBar.Content not in CommandBar.SecondaryCommands. Set OverflowButtonVisibility as Collapsed to hide the more button
<CommandBar OverflowButtonVisibility="Collapsed">
<CommandBar.Content>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<AppBarButton Icon="Back"
Label="Back"
IsCompact="False"
Name="WebViewBackButton"/>
<AppBarButton Icon="Forward"
Label="Forward"
IsCompact="False"
Name="WebViewForwardButton" Grid.Column="1"/>
</Grid>
</CommandBar.Content>
....
</CommandBar>
So Starting off small i want to find an IP address if an account has been logged out on my servers, I've made the GUI, its fine but the button doesn't work, any idea where I've gone wrong?
in theory it should return a string which contains an IP address, a time stamp and a date but i'm new to power shell so i'm not really 100% sure what i'm doing, any help would be appreciated
inputXML = #"
<Window x:Class="UnlockerGui.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="538.433">
<Grid HorizontalAlignment="Left" Width="538" Margin="0,0,-8,-21" RenderTransformOrigin="0.295,0.552">
<Grid.RowDefinitions>
<RowDefinition Height="101*"/>
<RowDefinition Height="239*"/>
</Grid.RowDefinitions>
<TextBox x:Name="TxtName" HorizontalAlignment="Left" Height="45" Margin="10,10,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="177"/>
<Button Grid.Row="0" x:Name="BtnSearch" Content="Search" HorizontalAlignment="Left" Margin="192,10,0,0" VerticalAlignment="Top" Width="271" Height="45"/>
<ListBox x:Name="LbResults" HorizontalAlignment="Left" Height="246" Margin="10,60,0,0" Grid.Row="0"
Grid.RowSpan="2" VerticalAlignment="Top" Width="504"/>
</Grid>
</Window>
"#
$inputXML = $inputXML -replace 'mc:Ignorable="d"','' -replace "x:N",'N' -replace '^<Win.*', '<Window'
[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
[xml]$XAML = $inputXML
#Read XAML
$reader=(New-Object System.Xml.XmlNodeReader $xaml)
try{$Form=[Windows.Markup.XamlReader]::Load( $reader )}
catch{Write-Host "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed."}
#===========================================================================
# Load XAML Objects In PowerShell
#===========================================================================
$xaml.SelectNodes("//*[#Name]") | %{Set-Variable -Name "WPF$($_.Name)" -Value $Form.FindName($_.Name)}
Function Get-FormVariables{
if ($global:ReadmeDisplay -ne $true){Write-host "If you need to reference this display again, run Get-FormVariables" -ForegroundColor Yellow;$global:ReadmeDisplay=$true}
write-host "Found the following interactable elements from our form" -ForegroundColor Cyan
get-variable WPF*
}
Get-FormVariables
#===========================================================================
# Actually make the objects work
#===========================================================================
#Sample entry of how to add data to a field
#$vmpicklistView.items.Add([pscustomobject]#{'VMName'=($_).Name;Status=$_.Status;Other="Yes"})
Function Get-Data{
param([string]$Localusername)
string[] $results1 =
Get-WinEvent -ComputerName SERVERNAME1 -FilterHashtable #{logname='security';id=4771;data=$Localusername} |
Select-Object -Property timecreated,
#{Name='computername';expression={$_.properties[6].value.Split(':')[3]}}
foreach($string in $results1)
{
$WPFLbResults.Items.Add($results1[$string])
}
string[] $results2 =
Get-WinEvent -ComputerName SERVERNAME2 -FilterHashtable #{logname='security';id=4771;data=$Localusername} |
Select-Object -Property timecreated,
#{Name='computername';expression={$_.properties[6].value.Split(':')[3]}}
foreach($string in $results2)
{
$WPFLbResults.Items.Add($results2[$string])
}
string[] $results3 =
Get-WinEvent -ComputerName SERVERNAME3 -FilterHashtable #{logname='security';id=4771;data=$Localusername} |
Select-Object -Property timecreated,
#{Name='computername';expression={$_.properties[6].value.Split(':')[3]}}
foreach($string in $results3)
{
$WPFLbResults.Items.Add($results3[$string])
}
}
#===========================================================================
# Shows the form
#===========================================================================
$Form.ShowDialog() | Out-Null
$WPFBtnSearch.Add_Click({
$username = $WPFTxtName.Text
Get-Data($username)
})
I have a resource:
<Application.Resources>
<PathIcon x:Key="appbar_share" Data="M10,16.6...http://modernuiicons.com/... />
</Application.Resources>
This resource renders fine when referenced through XAML:
<Page.BottomAppBar>
<CommandBar>
<AppBarButton Icon="{StaticResource appbar_share}" />
</CommandBar>
</Page.BottomAppBar>
But is not usable from code behind:
Dim Button1 As New AppBarButton
Dim MyPathIcon As PathIcon = _
TryCast(Application.Current.Resources("appbar_share"), PathIcon)
Button1.Icon = MyPathIcon
This is the error i get:
Similar exception can happen if your path data is not correct. Why does your PathIcon Data contain a link to modernuiicons.com? It shouldn't be there, it should have just the path data inside. For example:
<Application.Resources>
<PathIcon x:Key="appbar_share" Data="M41.1684,45.487038C44.33276,45.476124 47.116478,47.775484 47.619183,50.997017 48.173893,54.552612 45.741444,57.884518 42.186676,58.439186 38.631909,58.993855 35.299843,56.561596 34.745133,53.007202 34.189225,49.452806 36.621571,46.1208 40.176239,45.566132 40.509629,45.514019 40.841049,45.488167 41.1684,45.487038z M10.237135,35.558062L10.350618,35.901613C13.537862,45.15811,22.303875,51.450747,32.124443,51.476969L32.24012,51.475981 32.232979,51.574453C32.204815,52.168505 32.235886,52.774008 32.33125,53.384045 32.497891,54.451855 32.847706,55.446404 33.343685,56.340675L33.528836,56.655979 33.263104,56.66925C20.287924,57.165882,8.592234,48.699957,4.9941953,36.24795L4.991,36.236345 5.2068322,36.273844C6.0781415,36.403109 6.9829696,36.404837 7.8980048,36.262007 8.6605371,36.142996 9.3857501,35.930498 10.063782,35.638014z M6.5030173,20.89604C9.6663612,20.885077 12.450289,23.184638 12.954178,26.407125 13.508891,29.961675 11.076529,33.293532 7.521735,33.848207 3.9656423,34.402784 0.63486499,31.970687 0.078820122,28.416241 -0.47588428,24.861691 1.9564295,21.529734 5.5112136,20.975158 5.8444722,20.923035 6.1757749,20.897175 6.5030173,20.89604z M58.8219,18.574822L59.004681,19.084795C59.543209,20.648768 59.951763,22.281796 60.215809,23.973269 61.800083,34.122046 57.788403,43.852476 50.472401,50.025568L49.996003,50.417795 49.950493,50.167978C49.607575,48.524141,48.825226,47.070471,47.747254,45.912016L47.524395,45.683733 47.536305,45.673433C53.238133,40.622065 56.328049,32.862471 55.065937,24.777964 54.881249,23.594744 54.609913,22.446564 54.259404,21.338879L54.134854,20.961815 54.432953,20.907509C56.076813,20.564614,57.530503,19.782418,58.688969,18.704576z M52.585079,5.624033C55.74844,5.6138992 58.532292,7.9135618 59.036179,11.13474 59.590893,14.689362 57.158524,18.021196 53.603829,18.575868 50.047627,19.131741 46.715535,16.699662 46.16082,13.145139 45.606106,9.5893164 48.038472,6.2575331 51.59327,5.7028704 51.926533,5.6508484 52.25784,5.6250811 52.585079,5.624033z M32.156784,0.00014686584C37.614365,-0.017484665,42.811852,1.5448036,47.233734,4.3107109L47.724335,4.6257896 47.518517,4.7606697C46.206982,5.6667137,45.162045,6.9076052,44.488583,8.3395329L44.348809,8.6562643 43.997319,8.4421854C39.538208,5.7988148 34.168194,4.6310177 28.646389,5.4929276 20.363682,6.7857971 13.798057,12.32467 10.820051,19.546529L10.815107,19.558941 10.701824,19.495367C9.3059848,18.755269,7.7060798,18.377093,6.0457643,18.465707L5.6350406,18.498096 5.7456864,18.199476C9.2659248,9.0405502 17.451128,1.9652042 27.841681,0.34318161 29.291645,0.11686516 30.733063,0.0047473907 32.156784,0.00014686584z" />
</Application.Resources>
(Share icon path example taken from Metro Studio)
I'm having problems binding an variable color, which i have defined in a class, such that it can fill an area for me.
<UserControl x:Name="Portugal" x:Class="MiddleAgeWar1.UserControl_Portugal"
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:country="clr-namespace:MiddleAgeWar1.ViewModel"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="152" d:DesignWidth="88">
<Grid x:Name="LayoutRoot">
<Path x:Name="Path" Stretch="Fill" Fill="{Binding color}" StrokeThickness="1.34983" StrokeLineJoin="Round" Stroke="#D5000000" Data="F1 M 43.4622,0.674866C 43.4622,0.674866 42.2811,4.3869 42.1967,4.97748C 42.1124,5.56805 41.8593,5.56805 41.5218,6.07428C 41.1844,6.58038 41.5218,6.74921 41.0156,8.43646C 40.5094,10.1236 41.0156,9.44879 41.0156,10.883C 41.0156,12.3171 40.9313,12.1485 40.9313,12.1485L 42.028,14.7639C 42.028,14.7639 42.7873,17.7165 42.5342,19.1507C 42.2811,20.5849 41.8593,21.5974 41.2687,22.1035C 40.6782,22.6097 40.2563,23.7065 39.6658,24.0439C 39.0752,24.3813 38.7378,25.0562 37.3036,26.0687C 35.8694,27.081 36.713,27.8403 36.2912,28.8526C 35.8694,29.8649 36.1225,30.2868 35.8694,30.9617C 35.6163,31.6367 35.8694,34.252 35.8694,34.5894C 35.8694,34.9269 34.7727,38.0484 34.7727,38.0484C 34.7727,38.0484 34.5196,38.3858 33.001,40.6636C 31.4824,42.9415 32.3261,41.0855 31.145,41.9291C 29.9639,42.7728 29.7952,42.6041 28.6141,43.3633C 27.433,44.1226 28.1922,44.9662 28.0235,46.5692C 27.8548,48.1721 27.686,48.1721 27.686,49.0158C 27.686,49.8594 27.686,50.9561 27.686,52.3903C 27.686,53.8244 27.2642,54.3307 26.758,55.2587C 26.2519,56.1867 26.3362,55.9337 25.83,56.3555C 25.3238,56.7773 25.3238,56.6929 24.3115,57.1992C 23.2991,57.7053 23.6365,57.2835 23.2147,57.5366C 22.7929,57.7896 22.6242,58.2115 20.0089,61.3329C 17.3936,64.4544 19.1652,62.5141 18.659,63.4421C 18.1529,64.3701 18.406,64.0327 17.8998,65.045C 17.3936,66.0573 17.3936,66.1418 16.9718,66.9011C 16.5499,67.6602 16.5499,67.3228 15.5376,68.0821C 14.5252,68.8414 15.3688,68.6727 15.0314,69.1789C 14.6939,69.685 14.3565,69.6006 12.4161,71.0349C 10.4757,72.4691 11.8255,71.8785 11.0662,72.3847C 10.307,72.8908 10.307,72.8909 8.53531,73.5659C 6.76366,74.2407 6.84802,75.8437 6.84802,75.8437L 3.97963,78.2059C 2.79853,79.1339 3.64217,79.0495 3.30471,79.8931C 2.96726,80.7368 2.46107,82.7615 1.61742,83.6052C 0.773778,84.4488 1.53306,84.955 1.27997,85.5456C 1.02687,86.1362 0.183228,90.1013 1.02687,90.4387C 1.87052,90.7761 2.88289,90.6075 6.08874,90.3543C 9.29459,90.1013 6.84802,90.3543 9.04149,89.9326C 11.235,89.5107 10.5601,89.5107 11.6568,89.1733C 12.7535,88.8358 12.0786,89.1733 12.4161,89.342C 12.7535,89.5107 14.4408,91.7885 14.4408,92.5478C 14.4408,93.3071 14.4408,93.3914 14.1877,94.0663C 13.9346,94.7413 13.9346,94.7413 13.4284,95.1631C 12.9223,95.5849 12.2473,95.7537 11.4881,95.9224C 10.7288,96.091 9.9695,96.4285 8.61967,96.8504C 7.26985,97.2722 8.02912,97.1035 7.35421,97.3566C 6.67929,97.6097 7.10111,97.5253 4.73891,98.7908C 2.37671,100.056 4.73891,99.2126 4.73891,100.056C 4.73891,100.9 5.49819,100.9 6.00438,101.237C 6.51056,101.575 8.53531,101.912 10.3913,102.165C 12.2473,102.418 14.5252,102.587 14.5252,102.587L 15.875,103.768L 15.4532,106.89C 15.4532,108.493 15.4532,109.252 15.2845,111.445C 15.1157,113.639 14.947,112.373 14.4408,113.301C 13.9346,114.229 13.9346,114.483 13.091,116.254C 12.2473,118.026 12.7535,117.182 11.1506,119.46C 9.54769,121.738 10.307,121.569 10.0539,123.594C 9.80078,125.619 9.54768,124.353 8.19785,126.04C 6.84802,127.728 7.10111,127.559 6.34183,129.162C 5.58255,130.765 5.75128,129.921 4.48582,132.115C 3.22035,134.308 4.06399,133.043 3.64217,133.971C 3.22035,134.899 3.30471,135.996 3.22035,138.02L 3.97963,141.142C 4.82327,142.238 6.08874,143.166 8.70404,143.673C 11.3193,144.179 10.2226,144.601 11.6568,144.938C 13.091,145.276 13.5128,146.035 15.0314,146.71C 16.5499,147.385 16.2125,147.553 17.1405,147.722C 18.0685,147.891 18.9121,148.397 19.5871,148.482C 20.262,148.566 21.6962,148.903 22.5398,148.903C 23.3835,148.903 24.3115,148.819 24.3115,148.819L 28.9515,148.144L 31.2997,148.263C 31.2997,148.263 32.7128,148.179 33.2822,148.158C 33.8517,148.137 34.6532,148.137 36.0873,148.032C 37.5215,147.926 37.8801,147.926 38.6816,148.032C 39.483,148.137 41.8452,148.411 41.8452,148.411L 45.1354,148.924L 49.6958,151.635C 49.6958,151.635 49.4708,140.162 50.8207,130.713C 52.1705,121.264 46.9962,119.464 59.8196,106.866C 72.643,94.2674 73.7678,89.768 74.8927,87.0684C 76.0175,84.3687 75.7926,67.4958 76.0175,60.7466C 76.2425,53.9975 81.9441,38.369 83.2096,36.2598C 84.4751,34.1507 86.5842,28.0765 87.6809,19.1341C 88.7777,10.1916 66.5898,3.52667 65.24,2.7674C 63.8901,2.008 51.2355,3.18915 50.4762,2.34552C 49.7169,1.50189 43.5021,0.770813 43.4622,0.674866 Z " Margin="0,-0.001,-0.409,-0.309" UseLayoutRounding="False" />
<Grid HorizontalAlignment="Left" Height="100" VerticalAlignment="Top" Width="88"/>
</Grid>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
namespace MiddleAgeWar1.ViewModel
{
class Country
{
public SolidColorBrush color = new SolidColorBrush(Colors.Green);
}
}
I wish to bind the SolidColorBrush color such that it fills my area.
I think you should rearrange your code and start using MVVM.
You can easily get it to work through MVVM.
Go to Nuget and search for MVVM or Galsoft.
In Model you define what you want.
Then you can create your country as a View.
And then binding is easily done in ViewModel.
It will take some time to get into it. But when you do everything is easy from there!!
bind it to your grid like this..
<Grid HorizontalAlignment="Left" Height="100" VerticalAlignment="Top" Width="88" Background="{Binding color}"/>
and also implement InotifyPropetyChanged on your class ..it is good to do that...you can do that like this..
in your class do this..
class Country:INotifyPropertyChanged
{
public Country()
{
this.InitializeComponent();
this.DataContext = this;
}
private SolidColorBrush _color;
public SolidColorBrush color
{
get
{
return _color;
}
set
{
_color = value;
FirePropertyChanged("color");
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void FirePropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
I'm absolutely beginner to develop silverlight with RIA
i found the WCF RIA Services sample from silverlight.net by following the tutorial
i get an error while i trying to add new employee
it will pop up one window with message VS JIT Debugger
Code: 4004
Category: Managed Runtime Error
Message: System.ServiceModel.DomainServices.Client.DomainException: An error occurred while submitting changes on the Domain Context of type
I'm using silverlight 4 with AdventureWork2008Entities do this tutorial, and below are the code in the apps
<dataForm:DataForm x:Name="addEmployeeDataForm" AutoGenerateFields="False" AutoCommit="True" AutoEdit="True" CommandButtonsVisibility="None">
<dataForm:DataForm.EditTemplate>
<DataTemplate>
<StackPanel>
<dataForm:DataField Label="Business Entity ID">
<TextBox Text="{Binding BusinessEntityID, Mode=TwoWay}" />
</dataForm:DataField>
<dataForm:DataField Label="Login ID">
<TextBox Text="{Binding LoginID, Mode=TwoWay}" />
</dataForm:DataField>
<dataForm:DataField Label="National ID">
<TextBox Text="{Binding NationalIDNumber, Mode=TwoWay}" />
</dataForm:DataField>
<dataForm:DataField Label="Title">
<TextBox Text="{Binding JobTitle, Mode=TwoWay}" />
</dataForm:DataField>
<dataForm:DataField Label="Marital Status">
<TextBox Text="{Binding MaritalStatus, Mode=TwoWay}" />
</dataForm:DataField>
<dataForm:DataField Label="Gender">
<TextBox Text="{Binding Gender, Mode=TwoWay,NotifyOnValidationError=True, ValidatesOnExceptions=True }" />
</dataForm:DataField>
<dataForm:DataField Label="Salaried">
<CheckBox IsChecked="{Binding SalariedFlag, Mode=TwoWay,NotifyOnValidationError=True, ValidatesOnExceptions=True }" />
</dataForm:DataField>
<dataForm:DataField Label="Active">
<CheckBox IsChecked="{Binding CurrentFlag, Mode=TwoWay,NotifyOnValidationError=True, ValidatesOnExceptions=True }" />
</dataForm:DataField>
</StackPanel>
</DataTemplate>
</dataForm:DataForm.EditTemplate>
</dataForm:DataForm>
Employee Registration Window.xaml
private void addNewEmployee_Click(object sender, RoutedEventArgs e)
{
EmployeeRegistrationWindow addEmp = new EmployeeRegistrationWindow();
addEmp.Closed += new EventHandler(addEmp_Closed);
addEmp.Show();
}
private void addEmp_Closed(object sender, EventArgs e)
{
EmployeeRegistrationWindow emp = (EmployeeRegistrationWindow) sender;
if (emp.NewEmployee != null)
{
OrganizationContext _organizationContext = (OrganizationContext) (employeeDataSource2.DomainContext);
_organizationContext.Employees.Add(emp.NewEmployee);
employeeDataSource2.SubmitChanges();
}
}
Employee List.xaml.cs
public void InsertEmployee(Employee employee)
{
employee.HireDate = DateTime.Now;
employee.ModifiedDate = DateTime.Now;
employee.VacationHours = 100;
employee.SickLeaveHours = 0;
employee.rowguid = Guid.NewGuid();
employee.BirthDate = new DateTime(1967, 3, 18);
if ((employee.EntityState != EntityState.Detached))
{
this.ObjectContext.ObjectStateManager.ChangeObjectState(employee, EntityState.Added);
}
else
{
this.ObjectContext.Employees.AddObject(employee);
}
}
OrganizationService
I notice no-one has replied to this post, but thought I'd add a little info I have come across while researching the exact same problem, in case it helps someone, if not the original poster.
I assume you're using the AdventureWorks2008R2 database? If not please ignore the rest of this post!
Some of the column names have apparently changed since this Silverlight walkthrough was generated. In the Employee table, EmployeeID is now BusinessEntityID for example, and Title is now JobTitle. If you fix these references you will then get a different error, which is caused by ...
There is a Foreign Key relationship between the HumanResources.Employee table and the Person.Person table - if the Employee you're adding has no corresponding record in the Person table then the Insert will fail. So the code to insert an employee should first insert a record into the Person.BusinessEntity table and retrieve the resulting BusinessEntityID value. This BusinessEntityID value should then be used to insert relevant data into both the Person.Person and HumanResources.Employee tables.
At least, it looks that way to me. Hope this helps someone.
_Ade