Exchange Autodiscovery将通过该UserSettingName.UserDisplayName属性向我提供用户的显示名称.
但是,如果自动发现失败并且需要手动完成连接,我无法弄清楚如何获取DisplayName.
我尝试过这个,但我只是得到了用户的电子邮件地址:
_service = new ExchangeService();
_service.Credentials = new System.Net.NetworkCredential(exchangeSettings.EmailAddress, exchangeSettings.Password);
_service.Url = new Uri(exchangeSettings.ExternalEwsUrl);
NameResolutionCollection resolvedNames = _service.ResolveName(exchangeSettings.EmailAddress);
exchangeSettings.UserDisplayName = resolvedNames.First().Mailbox.Name;
Run Code Online (Sandbox Code Playgroud)
谢谢
我正在使用Mvvm-Light并且一直忽略了XAML中的绑定到目前为止是如何工作的.
这是我的XAML
<phone:PhoneApplicationPage.Resources>
</phone:PhoneApplicationPage.Resources>
<Grid x:Name="LayoutRoot" Background="Transparent">
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,14">
<TextBlock x:Name="ApplicationTitle" Text="{Binding SecuritySystemName}" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="{Binding PageName}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<TextBlock Name="textCode"
DataContext="{WHAT GOES HERE to bind to properties on my View (SecurityPanelPage class)}"
Text="{Binding Path=Code}" />
</Grid>
Run Code Online (Sandbox Code Playgroud)
{Binding SecuritySystemName}和{Binding PageName}正确绑定到我的ViewModel(SecuirtyPanelViewModel).但我希望TextBlock元素中的{Binding Code}绑定到我的VIEW(而不是ViewModel).
我搜索并搜索了解释DataContext和Binding支持的语法和值的文档和示例.没有任何帮助.
我想知道的是我如何设置一个DataContext(或指定一个指向我的View对象的{Binding ...}中的东西.我尝试过"Self"和各种"RelativeSource"的东西,但没有猜测是没有效率的,因为在解析XAML之前往返调试器的过程太长了.
谢谢.
更新 - 我找到了一个让我感动的答案,但我仍然没有理解,所以我对下面的精美海报提出了跟进问题.
这是有效的:
<phone:PhoneApplicationPage x:Name="ThisPage">
<TextBlock Name="textCode" Text="{Binding Code, ElementName=ThisPage"/>
</phone:PhoneApplicationPage>
Run Code Online (Sandbox Code Playgroud)
我在这里找到了这个提示:http://bursjootech.blogspot.com/2007/12/bind-from-xaml-to-local-property-in.html
他以不同的方式提出这个问题:如何"在XAML中绑定到代码隐藏的本地财产".
我仍然不明白下面提供的两个解决方案.以下更多问题......
我想在我的Mvvm-Light解决方案(WP7)中使用一个类(称为PremiseServer)来订阅从基类型派生的类的所有属性更改(SysObject是基类,它派生自ViewModel).
我有一组派生自SysObject的类.这些类具有不同类型的各种属性(字符串,布尔值,整数等...).
当任何这些类上的任何属性发生更改时,我希望我的PremiseServer实例看到这些更改,然后进行Web服务调用以将数据推送到服务器.
我已经尝试了这个,它永远不会被调用(这对我来说很有意义;因为正在改变的属性不是SysObject,而是SysObject的一些属性):
Messenger.Default.Register<PropertyChangedMessage<SysObject>>(this, (action) => {
String location = ((SysObject)action.Sender).Location; // URL to POST to
Debug.WriteLine("PremiseServer PropertyChange - " + action.NewValue.ToString());
});
Run Code Online (Sandbox Code Playgroud)
我也尝试了下面的(注册字符串消息),它可以工作,但我不想为每种属性类型创建其中一个:
Messenger.Default.Register<PropertyChangedMessage<String>>(this, (action) => {
String location = ((SysObject)action.Sender).Location; // URL to POST to
Debug.WriteLine("PremiseServer PropertyChange - " + action.NewValue.ToString());
});
Run Code Online (Sandbox Code Playgroud)
我也试过Register<PropertyChangeMessage<Object>想我会看到所有派生类型的消息(我没有).
我真正想要的是"从SysObject类的对象的任何属性注册所有属性更改密码".我怎样才能做到这一点?
谢谢!
Webmatrix中的WebSecurity组件非常流畅,但用户的会话对我来说过期太快.看起来好像以小时计算,我希望会话超时更多的是以天为单位.
如何更改会话超时?
Terminal.Gui (gui.cs)提供了Button一个Clicked定义为事件的类:
public event Action Clicked;
Run Code Online (Sandbox Code Playgroud)
我正在尝试在 PowerShell 中为 Terminal.Gui 编写一个示例应用程序,并且正在努力连接事件处理程序。
Add-Type -AssemblyName Terminal.Gui
[Terminal.Gui.Application]::Init()
$win = New-Object Terminal.Gui.Window
$win.Title = "Hello World"
$btn = New-Object Terminal.Gui.Button
$btn.X = [Terminal.Gui.Pos]::Center()
$btn.Y = [Terminal.Gui.Pos]::Center()
$btn.Text= "Press me"
# Here lies dragons
[Action]$btn.Clicked = {
[Terminal.Gui.Application]::RequestStop()
}
$win.Add($btn)
[Terminal.Gui.Application]::Top.Add($win)
[Terminal.Gui.Application]::Run()
Run Code Online (Sandbox Code Playgroud)
Clicked =上面示例中的赋值返回错误:
InvalidOperation: The property 'Clicked' cannot be found on this object. Verify that the property exists and can be set.
但是智能感知Clicked为我自动完成......所以我猜这是一个类型问题?
我找不到任何 PowerShell …
我有(注意Extras.WP7):
<phone:PhoneApplicationPage
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP7"
>
Run Code Online (Sandbox Code Playgroud)
...它对我的EventToCommand工作正常,如下所示:
<phone:PhoneApplicationPage.Resources>
<i:EventTrigger x:Key="KeyPadButtonTrigger" EventName="Click">
<cmd:EventToCommand Command="{Binding Path=KeyPadButtonCommand}" CommandParameter="{Binding ElementName=Self, Path=Content }" />
</i:EventTrigger>
</phone:PhoneApplicationPage.Resources>
Run Code Online (Sandbox Code Playgroud)
但后来我想用MmvmLight ButtonBaseExtensions这样:
<Button x:Name="button1"
cmd:ButtonBaseExtensions.Command="{Binding KeyPadButtonCommand}"
cmd:ButtonBaseExtensions.CommandParameter="{Binding ElementName=button1, Path=Content }"/>
Run Code Online (Sandbox Code Playgroud)
......但是当我这样做时,我得到了"The attachable property 'Command' was not found in type 'ButtonBaseExtensions'"错误.
我发现我必须添加一个名称空间assembly=GalaSoft.MvvmLight.WP7,如下所示:
<phone:PhoneApplicationPage
xmlns:cmdxtras="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP7"
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.WP7"
>
Run Code Online (Sandbox Code Playgroud)
请注意,我有两个xmlns:cmdxtras和xmlns:cmd.如果我只有一个或另一个,事情就不起作用了!
这看起来很笨拙,并没有与我认为别人的建议相提并论.为什么我需要两者?
MonoDevelop(2.10.8)正在报道:
JPGCorruptForm.cs(20,20): Warning CS0219: The variable `myStream' is assigned but its value is never used (CS0219) (JPGCorrupt)
Run Code Online (Sandbox Code Playgroud)
对于这个功能:
private void toolStripButtonChooseText_Click(object sender, EventArgs e)
{
Stream myStream = null;
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.InitialDirectory = ".";
openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog.FilterIndex = 1;
openFileDialog.RestoreDirectory = false;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
Stop();
try
{
if ((myStream = openFileDialog.OpenFile()) != null)
{
_settings.TextFile = openFileDialog.FileName;
CurrentTextFile = _settings.TextFile;
}
}
catch (Exception ex)
{
MessageBox.Show("Error: Could not …Run Code Online (Sandbox Code Playgroud) mvvm-light ×3
silverlight ×3
c# ×2
xaml ×2
.net ×1
mono ×1
monodevelop ×1
powershell ×1
razor ×1
terminal.gui ×1
webmatrix ×1