Sitecore custom dialog application remains empty - xaml

So I've created a small custom dialog application for sitecore that is called through a ribbon button which triggers a command which in turn triggers my custom control.
My command (which works in triggering the open dialog trigger):
var uri = UIUtil.GetUri("control:LanguageCopyModule");
var id = context.Items[0].ID.ToString();
var la = context.Items[0].Language;
var url = string.Format("{0}&id={1}&la={2}", uri, id, la.Name);
SheerResponse.ShowModalDialog(url);
The URL it generates in a popup window:
http://mydomain/sitecore/shell/default.aspx?xmlcontrol=LanguageCopyModule&id={E67AD356-3999-4D4C-ACE4-C570EFD1FBE0}&la=en
Untill this point it all works prefectly, but now when it opens my xml control window it just stays empty.
This is the code behind the xml:
<control xmlns:def="Definition" xmlns="http://schemas.sitecore.net/Visual-Studio-Intellisense">
<LanguageCopyModule>
<FormDialog Icon="Applications/16x16/paste.png" Header="Language Copy Module" Text="Copy field values between different languages." OKButton="Copy" CancelButton="Cancel">
<CodeBeside Type="MyAssembly.Modules.LanguageCopyModule.LanguageCopyModule,MyAssembly.Modules"/>
<GridPanel Columns="2">
<GridPanel.ColumnStyles>
<Column Width="70%" />
<Column Width="30%" />
</GridPanel.ColumnStyles>
<GridPanel.RowStyles>
<Row Height="100%" />
</GridPanel.RowStyles>
<!-- Fields -->
<FlowPanel>
<Border BorderThickness="1" BorderBrush="black">
<Text>Text</Text>
</Border>
</FlowPanel>
<!-- Languages -->
<FlowPanel>
<Border BorderThickness="1" BorderBrush="black">
<Button>Button</Button>
</Border>
</FlowPanel>
</GridPanel>
</FormDialog>
</LanguageCopyModule>
</control>
Any ideas as to why it remains empty? There's little documentation to be found and it could be I just missed something.
Thanks for any assistance!

This is regulated by the <controlSources> element in web.config. You can either put your XML control to any of the folders mentioned there, or add another control source. Note that there's a special "override" folder foreseen for such purpose. If you still need to add your own control source, remember that from Sitecore 6.0 it can be done in a pluggable configs (there's official Sitecore doc on this plus several blog posts out there).

I have found the issue: the .xml file NEEDS to be somewhere under /sitecore/shell in your filesystem.

Related

Reference string resource in Windows Phone 8.1 XAML

I am unclear how do I reference a control text property using string resources in Windows Phone 8.1?
For instance I have:
<HubSection x:Name="MySection" HeaderTemplate="{StaticResource MyHeaderTemplate}" Header="{StaticResource MyText}">
and
<AppBarButton Name="MyAppBar" Label="{StaticResource MyText}" ...>
and
They both reference MyText which I want to load from resource .resx file.
To Refer Any control Property from resources in the XAML, create a x:Uid for that control say for a TextBlock, I made a control like :
<TextBlock x:Uid="Header" Text="from Resx" Style="{ThemeResource TitleTextBlockStyle}"/>
And in the Resources.resx define a new Resource with name Header.Text and Value as desired say, My Header Text. See the screenshot below :

Windows phone toolkit ListPicker only allowing 5 elements

I have a simple working example:
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<toolkit:ListPicker>
<toolkit:ListPickerItem Content="FIRST" />
<toolkit:ListPickerItem Content="SECOND" />
<toolkit:ListPickerItem Content="THIRD" />
<toolkit:ListPickerItem Content="FOURTH" />
<toolkit:ListPickerItem Content="FIFTH" />
<toolkit:ListPickerItem Content="SIXTH" />
</toolkit:ListPicker>
</Grid>
create a new windows phone 8 app, install the windows phone toolkit nuget package, then add only the listpicker as shown above. It will blow. But, if you delete the sixth ListPickerItem, then it works.
Has anyone else gotten the listpicker to work? Do I need to add the items in code to get this to work?
by default list picker only allow 5 elements to show on the same view if it is more than that it will show it will take a full single view to show the elements and for that you have to add the elements from code behind. or you can change ItemCountThreshold.
The answer from souvickcse is not working anymore, because ItemCountThreshold is read-only now. Here's a "hack" which will work. Replace "ListPicker" with the Name you have given to your listpicker.
ListPicker.SetValue(Microsoft.Phone.Controls.ListPicker.ItemCountThresholdProperty, 100);

Windows 8 XAML Multilingual Translations

I've used the Multilingual Toolkit to translate my app and have been testing it using pseudo-language. It works fine for strings I have translated in code (C#) but I can't work out how to make it so that the tag in XAML is automatically translated.
I've been using http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh965329.aspx as a tutorial but I can't figure it out. I've also searched on Google but still no luck.
For example, I created a "Watermark" text box (which inherits from TextBox which shows some text in by default it the user has not entered any text and the item does not have focus. The XAML looks like this (I replaced generic positioning stuff with '...'):
<local:WatermarkTextbox x:Name="TitleTextBox" Watermark="MainPage_EnterATitle" ... Style="{StaticResource TextBoxStyle1}" />
As you can see it is setting a property called Watermark with a 'tag' of the resource name that is being translated using the Multilingual tool. I'm not sure how to get this to automatically translate.
Another example is using the bottom app bar buttons:
<Button x:Name="bottomAppBar_unpinFromStartButton" AutomationProperties.Name="MainPage_UnpinFromStart" Style="{StaticResource UnPinAppBarButtonStyle}" Click="bottomAppBar_unpinFromStartButton_Click"/>
And I can see in the link above that it says:
MediumButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name
But I'm not really sure where this is meant to go.
Even with a button, which seems like it would be the simplest to translate I can't get it to work. The XAML is:
<Button x:Name="RemovePhotoButton" x:Uid="MainPage_RemovePhoto" Content="" HorizontalAlignment="Center" Margin="222,0,974,78" Grid.Row="1" VerticalAlignment="Bottom" Width="170" Height="45"/>
But when ran in the app or viewed in the designed the button stays blank, with no text on it.
The Resources are set up like this:
And it is filling the translated documents fine:
I am able to translate it in C# using the code from the link above, just not using XAML.
Just wondering if anybody could help me out or point me in the right direction to solve this.
Thanks
First what i think is missing in the name of your resources is the property that you want to set. While never used it myself, i would understand it like this:
Your xaml needs to be changed to
<local:WatermarkTextbox x:Name="TitleTextBox" x:Uid="MainPage_EnterATitle" Watermark="" ... Style="{StaticResource TextBoxStyle1}" />
And your resource needs an entry with the key
MainPage_EnterATitle.Watermark
And about the part with the
MediumButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name
This is only used if the referenced property is an attached property. Like if your Watermark property would be attached not part of the control. But in your case its not important.

Windows 8 bottom app bar

I've been trying to get an App bar implemented in a WinRT metro app (C# / XAML), but don't know where to begin. I've tried using the <ApplicationBar/> tag and I get a Type not found error.
There's no help online, could someone update this post with the answer so that it'll serve as a reference to other programmers as well?
There's only a JavaScript sample which isn't of much help.
This should work:
<AppBar
VerticalAlignment="Bottom">
<Button
AutomationProperties.Name="Play"
Style="{StaticResource PlayAppBarButtonStyle}"
Command="{Binding PlayCommand}" />
</AppBar>
– you would put that in the layout root grid of your page.
*EDIT
Note: According to documentation - you should put it in Page.BottomAppBar property, although at least in Windows 8 Consumer Preview - it works fine when used in any Grid, which is convenient if your UI isn't tightly coupled to a Page control.
*EDIT 2, response from MSFT:
The recommended approach is to use the Page.BottomAppBar/TopAppBar properties.
There are known hit-testing issues in the Consumer Preview if AppBars are added without using these properties
The AppBars do not use the proper animations if they are added without using these properties
If AppBars are added as children of arbitrary elements then it's easier for multiple controls to attempt to create/modify AppBars, resulting in an inconsistent user experience
*EDIT 3
The CustomAppBar in WinRT XAML Toolkit can be used anywhere, animates based on Vertical/Horizontal-Alignment, can have other content overlaid on top of it and also has a CanOpen property that allows to block it from opening.
<Page.TopAppBar>
<AppBar>
<TextBlock x:Name="TextBlock1" Text="Sample Text" Margin="0,0,0,0" Height="Auto" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</AppBar>
</Page.TopAppBar>

Silverlight - displaying graphical resources within a button

Has anyone solved this: displaying graphical resources within a button
create a resource, for instance a rectangle
<UserControl.Resources>
<Rectangle x:Key="myRectangle" Fill="Red" Height="100" Width="100"/>
</UserControl.Resources>
then set the content of the button to the resource
<Button Content="{StaticResource myRectangle}"/>
when you build inside blend 4 RC you get the error "Value does not fall within the expected range."
Visual studio does not show this error.
When you run the site the button doesn't show any content.
This technique works in WPF without problems.
Anyone got any ideas?
This can be done by directly setting the shape as the button's content. For eg:
<Button Height="120" Width="120">
<Rectangle Fill="Red" Height="100" Width="100"/>
</Button>
FrameworkElement.Resources are generally used for storing nonvisual elements, brushes, etc. For your case (I think) you'll need to store your xaml as a data template, again not sure if this works with Buttons, it is used for things like ListBoxes. See here:
resources description on msdn. The link further contains pointers to information for Data Templates etc.